因为刚学vue然后自己自习了一下axios,然后想写一个简单的查询后台数据


{{user.id}}

{{user.name}}

{{user.gender}}





{{user.id}}

{{user.name}}

{{user.gender}}



然后先是写了这样一个代码
created: function () {


axios.get("http://localhost:8080/student/findAll").then(function (response) {

this.uList = response.data;

console.log(uList);

}).catch(function (reason) {


})

}
created: function () {


axios.get("http://localhost:8080/student/findAll").then(function (response) {

this.uList = response.data;

console.log(uList);

}).catch(function (reason) {


})

}
然后后台可以获取到数据,但是无法显示到table上面发现this.uList虽然改变的数据但是数据无法显示到table上面然后发现这里的this不是外部的this对象,然后进行了更改,数据就回显了
new Vue({

el:'#app',

data:{

uList:[],

},

created: function () {

var arr = this;

axios.get("http://localhost:8080/student/findAll").then(function (response) {

arr.uList = response.data;

console.log(uList);

}).catch(function (reason) {


})

}
})
new Vue({

el:'#app',

data:{

uList:[],

},

created: function () {

var arr = this;

axios.get("http://localhost:8080/student/findAll").then(function (response) {

arr.uList = response.data;

console.log(uList);

}).catch(function (reason) {


})

}
})补充知识:vue data有值,但是页面{{}} 取不到值
补充知识:补充知识:vue data有值,但是页面{{}} 取不到值我的问题出在js引入的顺序不对,导致不能正常显示vue中的值正确的顺序应该是:正确的顺序应该是:先引入vue的js--------html代码-----最后引入自己写的js以上这篇浅谈vue获得后台数据无法显示到table上面的坑就是小编分享给大家的全部内容了,希望能给大家一个参考。