内射老阿姨1区2区3区4区_久久精品人人做人人爽电影蜜月_久久国产精品亚洲77777_99精品又大又爽又粗少妇毛片

Vue如何獲取數(shù)據(jù)列表展示-創(chuàng)新互聯(lián)

這個(gè)例子從 Github 的 API 中獲取了最新的 Vue.js 提交數(shù)據(jù),并且以列表形式將它們展示了出來(lái)。你可以輕松地切換 master 和 dev 分支。

成都創(chuàng)新互聯(lián)-成都網(wǎng)站建設(shè)公司,專注做網(wǎng)站、網(wǎng)站設(shè)計(jì)、網(wǎng)站營(yíng)銷推廣,申請(qǐng)域名,網(wǎng)站空間,網(wǎng)站運(yùn)營(yíng)有關(guān)企業(yè)網(wǎng)站制作方案、改版、費(fèi)用等問(wèn)題,請(qǐng)聯(lián)系成都創(chuàng)新互聯(lián)。

一、展示

Vue如何獲取數(shù)據(jù)列表展示

二、源碼

<!DOCTYPE html>
<html lang="en">
<head>
 <meta charset="UTF-8">
 <meta name="viewport" content="width=device-width, initial-scale=1.0">
 <meta http-equiv="X-UA-Compatible" content="ie=edge">
 <title>Document</title>
 <script src="https://cdn.jsdelivr.net/npm/vue@2.6.7/dist/vue.js"></script>
</head>
<body>
 <div id="app">
  <h3>title</h3>
  <template v-for="(branch, index) in branches">
   <input type="radio" 
    :id=index 
    :value="branch" 
    v-model="currentBranch"
   />
   <label :for="index">{{ branch }}</label>
  </template>
  <div>當(dāng)前選定:{{ currentBranch }}</div>
  <ul>
   <li v-for="item in getData">
    <a :href="item.html_url" rel="external nofollow" >{{ item.sha.slice(0, 7) }}</a>
    - <span>{{ item.commit.message }}</span><br/>
    <span>創(chuàng)建人:<a :href="item.author.html_url" > {{ item.commit.author.name }}</a></span><br/>
    <span>創(chuàng)建時(shí)間:{{ item.commit.author.date | formatDate }}</span>
   </li>
  </ul>
 </div>

 <script>
  let apiURL = 'https://api.github.com/repos/vuejs/vue/commits?per_page=3&sha='
  let vm = new Vue({
   el: '#app',
   data() {
    return ({
     branches: ['master', 'dev'],
     currentBranch: 'master',
     getData: null,   
    });
   },
   created() {
    this.fetchDate();
   },
   watch: {
    currentBranch: 'fetchDate'
   },
   filters: {
    formatDate(v) {
     return v.replace(/T|Z/g, ' ');
    }
   },
   methods: {
    fetchDate() {
     var xhr;
     if(window.XMLHttpRequest) {
      xhr = new XMLHttpRequest();
     }else {
      xhr = new ActiveXObject("Microsoft.XMLHTTP");
     }
     let self = this;
     
     xhr.onload = function() {
      if(xhr.readyState == 4) {
       if(xhr.status >= 200 && xhr.status < 300 || xhr.status == 304) {
        self.getData = JSON.parse(xhr.responseText);
       }else {
        console.error(xhr.status, xhr.statusText);
       }
      }
     }
     xhr.open('GET', apiURL + this.currentBranch);
     xhr.send(null);
    }
   },
  });
 </script>
</body>
</html>

本文標(biāo)題:Vue如何獲取數(shù)據(jù)列表展示-創(chuàng)新互聯(lián)
文章路徑:http://www.rwnh.cn/article0/dgheoo.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供做網(wǎng)站、關(guān)鍵詞優(yōu)化、網(wǎng)站策劃、企業(yè)建站、面包屑導(dǎo)航、域名注冊(cè)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

h5響應(yīng)式網(wǎng)站建設(shè)
甘谷县| 建水县| 仲巴县| 新沂市| 霍城县| 文登市| 牙克石市| 青田县| 晴隆县| 秦安县| 高平市| 仙居县| 新民市| 界首市| 麻栗坡县| 肇东市| 麻阳| 沛县| 杭州市| 平顶山市| 罗定市| 华阴市| 洮南市| 梅州市| 平安县| 石狮市| 鄂温| 金溪县| 庆安县| 深圳市| 理塘县| 金寨县| 博客| 江山市| 岑巩县| 双峰县| 林口县| 当阳市| 江津市| 韶关市| 南涧|