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()方法,将它用成了变量,只需要加个()

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐