Property or method "nochildren" is not defined on the instance but referenced during render. Make sure that this property is reactive
<template>
<el-menu default-active="1-4-1" class="el-menu-vertical-demo" @open="handleOpen" @close="handleClose" :collapse="isCollapse">
<el-menu-item v-for="item in nochildren" :index="item.path" :key="item.path">
<i :class="'el-icon-' + item.icon"></i>
<span slot="title">{{item.label}}</span>
</el-menu-item>
<el-submenu index="1">
<template slot="title">
<i class="el-icon-location"></i>
<span slot="title">导航一</span>
</template>
<el-menu-item-group>
<span slot="title">分组一</span>
<el-menu-item index="1-1">选项1</el-menu-item>
</el-menu-item-group>
</el-submenu>
</el-menu>
</template>
<style>
.el-menu-vertical-demo:not(.el-menu--collapse) {
width: 200px;
min-height: 400px;
}
</style>
<script>
export default {
data() {
return {
isCollapse: false,
menu:[
{
path:'/',
name:'home',
label:'首页',
icon:'s-home',
url:'Home/Home'
},
{
path:'/mall',
name:'mall',
label:'商品管理',
icon:'video-play',
url:'MallManage/MallManage'
},{
path:'/user',
name:'user',
label:'用户管理',
icon:'user',
url:'UserManage/UserManage'
},{
label:'其他',
icon:'location',
children:[
{
path: '/page1',
name: 'page1',
label: '页面1',
icon: 'Other/PageOne'
},
{
path:'/page2',
name:'page2',
label:'页面2',
icon:'setting',
url:'Other/PageTwo'
}
]
}
]
};
},
methods: {
handleOpen(key, keyPath) {
console.log(key, keyPath);
},
handleClose(key, keyPath) {
console.log(key, keyPath);
}
},
computed:{
noChildren(){
return this.menu.filter(item => !item.children)
},
hasChildren(){
return this.menu.filter(item => item.children)
}
}
}
</script>
<script>
export default {
name: "CommonAside"
}
</script>
<style scoped>
</style>
今天写vue项目,遇到一个问题
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
2条回答 默认 最新
- go_with_dream 2022-05-05 22:37关注
data里没有noChildren,请在data return 里34行和35行之间加上 noChildren:[],
解决 无用评论 打赏 举报
悬赏问题
- ¥20 Html备忘录页面制作
- ¥15 黄永刚的晶体塑性子程序中输入的材料参数里的晶体取向参数是什么形式的?
- ¥20 数学建模来解决我这个问题
- ¥15 计算机网络ip分片偏移量计算头部是-20还是-40呀
- ¥15 stc15f2k60s2单片机关于流水灯,时钟,定时器,矩阵键盘等方面的综合问题
- ¥15 YOLOv8已有一个初步的检测模型,想利用这个模型对新的图片进行自动标注,生成labellmg可以识别的数据,再手动修改。如何操作?
- ¥30 NIRfast软件使用指导
- ¥20 matlab仿真问题,求功率谱密度
- ¥15 求micropython modbus-RTU 从机的代码或库?
- ¥15 django5安装失败