1.cnpm install axios --save-dev
2.main.js文件中引入
import axios from 'axios'
3.将axios改写为Vue的原型属性
Vue.prototype.$axios=axios;
4.在组建中使用
getkind(){
var _this=this
var url="/api/public/index.php/index/cate/main?pid=0";
this.$axios({
method: 'get',
url: url,
}).then(function(res){
console.log(res.data)
}).catch(function(err){
console.log(err)
})
网友评论