咨询大家一个axios 和vue的问题
$(function () {
var self = this;
var vm = new Vue({
el: "#app",
data: {
MenuList: []
},
mounted() {
this.getMenuList();
},
methods: {
getMenuList: function () {
//有值,而且MenuList调试发现也赋值了,但是前台列表不显示数据
axios.get('/Menu/MenuList').then(
function (response) {
this.MenuList= response.data.data;
}).catch(function (error) {
console.log(error);
});
//也有值,列表显示了查询的数据
axios.get('/Menu/MenuList').then((response) => {
this.MenuList= response.data.data;
}
).catch(function (error) {
console.log(error);
});
//根据百度的结果,然后吧第一个方法这样改了下,还是不行
axios.get('/Menu/MenuList').then(
function (response) {
self.MenuList= response.data.data;
}).catch(function (error) {
console.log(error);
});
//根据百度的结果,又改成了这样,依然不行
axios.get('/Menu/MenuList').then(
function (response) {
Vue.set(app, 'MenuList', response.data.data)
}).catch(function (error) {
console.log(error);
});
}
}
});
});