vuejs报错:[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

—->at src/app.vue

原因:
1、必须引入router配置

复制
// 路由配置
import routes from “./routes”;
// 实例路由配置
const router = new VueRouter(routes);
router.js

复制
import Index from ‘./pages/index/index.vue’;
export default {
mode: ‘history’,
scrollBehavior(to, from, savedPosition) {//切换路由滚动至顶部
return { x: 0, y: 0 };
},
routes: [
// 首页
{
path: ‘/’,
component:Index
},
]
}
2、根实例中必须加入router配置

复制
/**

  • 创建根实例
    */
    var vue = new Vue({
    el: “#app”,
    // 引入路由实例
    router,
    render: h => h(App)
    });

你可能感兴趣的:(vuejs报错:[Vue warn]: Error in render: TypeError: Cannot read property 'matched' of undefined)