我是Vue js的新手。
我试图将json解析到html表中。
<tr v-for="(item) in products">
<td>{{item.id}}</td>
</tr>
但是表打印空行。如果我想打印
<td>{{item}}</td>
然后,每行打印json的单个字符。
我的儿子:"{id:'mu'}"
我错了。拜托,一点指导会有帮助的。
var app4 = new Vue({
el: '#Itemlist',
data: {
products: []
},
mounted: function (){
var self = this;
$.ajax ({
url: "getAll",
method: "GET",
success: function (data) {
self.products = "{id: 'mu'}";
},
error: function(error) {
console.log(error)
}
});
}
})
发布于 2018-05-08 11:36:34
var app4 = new Vue({
el: '#Itemlist',
data: {
products: []
},
mounted: function (){
var self = this;
$.ajax ({
url: "getAll",
method: "GET",
success: function (data) {
// this is your issue
//self.products = "{id: 'mu'}";
self.products.push({id: 'mu'});
},
error: function(error) {
console.log(error)
}
});
}
})
https://stackoverflow.com/questions/50232374
复制相似问题