【发布时间】:2020-11-05 14:02:33
【问题描述】:
虽然输出是正确的。我有这个错误:无法读取未定义的属性“状态”。我怀疑这是因为在 ajax 调用之后添加了列表。我该如何改进?
<template v-for="status in showStatus">
<div class="col-sm-1">{{status}}</div>
</template>
<script>
var app = new Vue({
el: "#app",
data: {
listing: []
},
created: function(){
axios.get('/getListing')
.then(function (response) {
app.listing = response.data;
})
.catch(function (error) {
console.log(error);
});
},
computed: {
showStatus(){
return this.listing[0].status;
}
}
});
</script>
【问题讨论】:
-
<template>是您组件的根模板吗?