Error in render: TypeError: Cannot read property '' of undefined[Vue 警告]:渲染错误:TypeError: Cannot read property \\'object\\' 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 .post("http://localhost:3000/listCategoriesByMID", { id: 1}) .then(response => { this.topMenuItem1 = response.data; console.log("topMenuItem1:" + this.topMenuItem1 +"" + JSON.stringify(this.topMenuItem1)); }); axios .post("http://localhost:3000/listCategoriesByMID", { id: 2}) .then(response => { this.topMenuItem2 = response.data; console.log("topMenuItem2:" + this.topMenuItem2 +"" + JSON.stringify(this.topMenuItem2)); }); axios .post("http://localhost:3000/listMainCategories") .then(response => { this.topMenu = response.data; console.log("topMenu:" + this.topMenu +"" + JSON.stringify(this.topMenu)); }); }, |
一般规则是永远不要在模板中使用
所以把
相关讨论
沃梦达教程
本文标题为:关于 json:渲染中的错误:”TypeError:无法读
基础教程推荐
猜你喜欢
- js禁止页面刷新与后退的方法 2024-01-08
- 浅析canvas元素的html尺寸和css尺寸对元素视觉的影响 2024-04-26
- JS前端广告拦截实现原理解析 2024-04-22
- 浅谈Vue2和Vue3的数据响应 2023-10-08
- 关于文字内容过长,导致文本内容超出html 标签宽度的解决方法之自动换行 2023-10-28
- CSS3的几个标签速记(推荐) 2024-04-07
- 基于Vue制作组织架构树组件 2024-04-08
- Ajax实现动态加载数据 2023-02-01
- vue离线环境如何安装脚手架vue-cli 2025-01-19
- this[] 指的是什么内容 讨论 2023-11-30
