TypeError: Cannot use ‘in‘ operator to search for ‘path‘ in null

runtime-core.esm-bundler.js?d2dd:218 Uncaught TypeError: Cannot use 'in' operator to search for 'path' in null
    at resolve (vue-router.mjs?f169:2998:1)
    at pushWithRedirect (vue-router.mjs?f169:3117:1)
    at Object.push (vue-router.mjs?f169:3082:1)
    at Proxy.handleMenuItemClick (menu.ts?63da:133:1)
    at Proxy.handleClick (menu-item.vue?e987:89:1)
    at onClick._cache.<computed>._cache.<computed> (menu-item.vue?e987:10:1)
    at callWithErrorHandling (runtime-core.esm-bundler.js?d2dd:155:1)
    at callWithAsyncErrorHandling (runtime-core.esm-bundler.js?d2dd:164:1)
    at HTMLLIElement.invoker (runtime-dom.esm-bundler.js?2725:369:1)

解决方法:
el-menu里面使用了router属性
el-menu-item 需要写index=“xx”,这样路由跳转才不会报错
Cannot use ‘in’ operator to search for ‘path’ in null

  <el-menu
      active-text-color="#ffd04b"
      background-color="#2d3a4b"
      class="el-menu-vertical-demo"
      default-active="home"
      text-color="#fff"
      router
  >
  <el-menu-item index="#">
        <el-icon @click="logout"><switch-button /></el-icon>
        <span @click="logout">安全退出</span>
  </el-menu-item>

搜索了好久都是
第一种:TypeError: Cannot use ‘in‘ operator to search for ‘path‘ in undefined
router-link to属性没写

第二种:用错了createWebHashHistory()方法,将它用成了变量,只需要加个()

  • 10
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值