Vue Axios的配置 (高仿饿了么)
生活随笔
收集整理的這篇文章主要介紹了
Vue Axios的配置 (高仿饿了么)
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
export default {name: "app",components: {"v-header": header},data() {return {seller: {}};},created() {let _this = this; // 讓this始終代表最初this指向的對(duì)象this.axios.get('../data.json').then(function(res) {_this.seller = res.data.sellerconsole.log(_this.seller)// }
}).catch(error => {console.log(error);});}
};
</script>
上代碼生效的前提
import Vue from 'vue' import axios from 'axios'Vue.prototype.axios = axios // 也可以 Vue.prototype.$http = axios , this.axios... 就要改為 this.$http...?
轉(zhuǎn)載于:https://www.cnblogs.com/footstep/p/7930183.html
總結(jié)
以上是生活随笔為你收集整理的Vue Axios的配置 (高仿饿了么)的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: php创建分页类,一个最强的PHP通用分
- 下一篇: vuejs滚动条_vuescroll-一