首页 > 解决方案 > 类型错误:在 vue 中使用路由器链接时无法读取未定义的属性“_normalized”

问题描述

我在 Vue 组件中使用以下路由器链接:

 <router-link :to="{ name: 'home'}"></router-link>

我的应用程序的其余部分如下:

路由器.js

  new VueRouter({
  mode: "history",
  routes: [
    {
      name: 'home',
      path: '/home',
      component: home,
    }
 ]})

主.js

new Vue({
  render: (h) => h(App),
  router,
}).$mount("#app");

使用 router-link 时出现以下错误,但 router.push() 与路由正常工作。

TypeError: Cannot read property '_normalized' of undefined (vue.min.js:6)

标签: vue.js

解决方案


在你的 Vue 组件中使用

<router-link to="/home"></router-link>

推荐阅读