亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

vue如何從接口請(qǐng)求數(shù)據(jù)

 更新時(shí)間:2017年06月22日 09:46:07   作者:Kymming  
本篇文章主要介紹了vue如何從接口請(qǐng)求數(shù)據(jù) ,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧

這兩天學(xué)習(xí)了vue如何從接口請(qǐng)求數(shù)據(jù),所以,今天添加一點(diǎn)小筆記。

<!doctype html>

<html>

  <head>

    <meta charset="UTF-8">

    <title>獲取圖片列表</title>

    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />    

  </head>

  <body>

    <div id="app">

      <ul>

        <li>

          <img v-for="imgItem in imgList" v-bind:src="imgItem.img" alt="" width="100%" height="100%"/>

        </li>

      </ul>

    </div>    

  </body>

  <script src="http://cdn.bootcss.com/vue/2.1.0/vue.js" type="text/javascript" charset="utf-8"></script>

  <script src="http://cdn.bootcss.com/vue-resource/1.0.3/vue-resource.js" type="text/javascript" charset="utf-8"></script>

  <script>

    var demo=new Vue({

      el:'#app',

      data: {

        imgList:[],

        getImgUrl: ''  //存數(shù)據(jù)接口        

      },

      created: function(){

        this.getImg()       //定義方法

      },

      methods: {

        getImg: function(){

          var that = this;    

          that.$http({      //調(diào)用接口

            method:'GET',

            url:this.getImgUrl //this指data

          }).then(function(response){ //接口返回?cái)?shù)據(jù)

            this.imgList=response.data;             

          },function(error){

          })

        }

      }

    })

  </script>

</html>

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論