api接口:http://www.phonegap100.com/appapi.php?a=getPortalList&catid=20&page=1
一、vue-resource(官方)
1.安装 npm install vue-resource --save
2.在main.js引入
import VueResource from 'vue-resource'
Vue.use(VueResource );
3.在组件中直接使用
this.$http.get(地址).then((response)=>{
console.log(response)
},(error)=>{
console.log(error)
})
二、axios
1.安装 npm install axios --save
2.那里用那里引入axios
import Axios from 'axios';
3.Axios.get(api).then((response)=>{
console.log(response);
}).catch((error)=>{
console.log(error);
})
网友评论