Error in render: “TypeError: Cannot read property ” of undefined”
[Vue 警告]:渲染错误:”TypeError: Cannot read property \\’object\\’ of undefined”
这个 v-for 很好用
|
1
2 3 4 5 6 7 8 |
<p class=”horizontal-menu-item-link” v-on:mouseover=”isMouseover1=true” v-on:mouseleave=”isMouseover1=false”>{{item.name}}</p>
<h2 class=”horizontal-menu-title robot-header-horizontalMenu-title”> <i class=”icon-container gg-icon gg-icon-menu-phone”> Elektronik Kategorisi <i class=”gg-icon gg-icon-pagination-arrow-right”> |
这里出错了。
|
1
2 |
<h3 class=”sub-title robot-header-horizontalMenu-subTitle” v-for=”(item2, index2) in this.object.topMenuItem1″ :key=”index2″>
{{item2.id}} |
Vue 运行良好。我正在使用 axios 获取数据。并在模板中使用 v-for 显示。我可以轻松获得 topMenu。使用相同的方法获取 topMenuItem1。但是当我在模板中使用 v-for 时,出现打字错误。我的失败在哪里?
|
1
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
data() {
return { //top menü topMenu: null, topMenuItem1: null, topMenuItem2: null, } },
mounted: function mounted () { axios |
一般规则是永远不要在模板中使用this:可能的解释
所以把 ths.object.topMenuItem1 改成 topMenuItem1
- 哦谢谢。我忘记了删除对象。但为什么 ?不应该使用”this”吗?
来源:https://www.codenong.com/60867218/
