export default {name: "app",components: {"v-header": header},data() {return {seller: {}};},created() {let _this = this; // 让this始终代表最初this指向的对象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...