这里是文章模块栏目内容页
[Vue warn]: Error in render: "TypeError: Cannot read property 'matched' of undefined"

[Vue warn]: Error in render: "TypeError: Cannot read property 'matched' of undefined"

错误的具体显示:

found in

---> <App> at src/App.vue
       <Root>
 
vue.esm.js?efeb:1897 TypeError: Cannot read property 'matched' of undefined
  
vue.esm.js?efeb:9077 Download the Vue Devtools extension for a better development experience:
https://github.com/vuejs/vue-devtools
sockjs.js?3600:1605 XHR finished loading: GET "http://localhost:8081/sockjs-node/info?t=1609384807252".
 
:8081/#/index:1 Error in event handler for runtime.onMessage: TypeError: Cannot read property 'join' of undefined
    at Object.getPageLang (chrome-extension://hlppekcioiicbfafmmgikkdkljnjpiao/content.js:1:8920)
    at chrome-extension://hlppekcioiicbfafmmgikkdkljnjpiao/content.js:8:46945

错误原因:

在new Vue()的实例中对路由名称的识别是唯一的,所以 route 并不能被识别,所以需要修改为【router】

/* eslint-disable no-new */
window.Vue = new Vue({
    el: '#app',    
    template: '<App/>',  
    Router, //这个地方要固定写router 这个单词,Vue才能识别。哪怕是大小写不一致。都会报错
    components: { App },
    render: h => h(App)
})

另外,在配置路由的时候,还需要注意routes这个也是固定的,如图:

import Vue from 'vue'
import VueRouter from 'vue-router'
import Index from '../pages/index.vue'
Vue.use(VueRouter);
export default new VueRouter({
   routes:[ //这个routes单词也是固定属性,写其他无法识别
       {
           path:'',
           redirect: '/index'
       }
       ,{
            path: '/',
            redirect: '/index'
        }
       ,{
           path:'/index',
           name: 'Login',
           component: Index
       }
   ]
})


Vue 的文档看起来简单,动手去搭建个项目进行调试开发时,就会遇到不少问题,值得记录一下。

 好了,本文内容全部结束,感谢您的阅读。