Morning, 2022-05-05 22:15 采纳率: 50%
浏览 92

今天写vue项目,遇到一个问题

 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>
  • 写回答

2条回答 默认 最新

  • go_with_dream 2022-05-05 22:37
    关注

    data里没有noChildren,请在data return 里34行和35行之间加上 noChildren:[],

    评论

报告相同问题?

问题事件

  • 创建了问题 5月5日

悬赏问题

  • ¥100 需要跳转番茄畅听app的adb命令
  • ¥50 寻找一位有逆向游戏盾sdk 应用程序经验的技术
  • ¥15 请问有用MZmine处理 “Waters SYNAPT G2-Si QTOF质谱仪在MSE模式下采集的非靶向数据” 的分析教程吗
  • ¥50 opencv4nodejs 如何安装
  • ¥15 adb push异常 adb: error: 1409-byte write failed: Invalid argument
  • ¥15 nginx反向代理获取ip,java获取真实ip
  • ¥15 eda:门禁系统设计
  • ¥50 如何使用js去调用vscode-js-debugger的方法去调试网页
  • ¥15 376.1电表主站通信协议下发指令全被否认问题
  • ¥15 物体双站RCS和其组成阵列后的双站RCS关系验证