六请求接口

<template>
    <div>
        <button @click="getDio()">vueresource请求接口</button><br>
         <button @click="getAxios()">axios请求接口</button>
        <br>
        <ul>
            <li v-for="(item,index) in list" :key="index">
                {{item.title}}
            </li>
        </ul>
        <br>
       
        
    </div>
</template>

<script>
/**
 * vue-resource
 * axios
 * fetch-jsonp
 * 
 */
import  Axios from 'axios'

export default {
    name:'Home',
    data() { 
        return {
              url:"http://www.phonegap100.com/appapi.php?a=getPortalList&catid=1&page=1",
              list:[],
              lista:[]
        }
    },
       methods: {
           getDio(){
                  
                  this.$http.get(this.url).then(function(respose){
                      console.log(respose.body);
                      this.list=respose.body.result;
                  },function(error){
                  console.log(error);
                  });
           },
           getAxios(){
                Axios.get(this.url).then((response) =>{
                 console.log( response.data.result);
                 this.list= response.data.result;
                 console.log( this.list);
                }).catch((error)=>{
                      console.log(error);
                })
           }
       },
}
</script>

<style scoped>

</style>
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容