首页
Javascript
Html
Css
Node.js
Electron
移动开发
小程序
工具类
服务端
浏览器相关
前端收藏
其他
关于
公司注册

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

2018年10月22日 发布 阅读(7893) 作者:Jerman

记录报错:

[Vue warn]: Error in render: “TypeError: Cannot read property ‘matched’ of undefined”

found in

—->at src/app.vue

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

  1. // 路由配置
  2. import routes from "./routes";
  3. // 实例路由配置
  4. const router = new VueRouter(routes);

router.js

  1. import Index from './pages/index/index.vue';
  2. export default {
  3. mode: 'history',
  4. scrollBehavior(to, from, savedPosition) {//切换路由滚动至顶部
  5. return { x: 0, y: 0 };
  6. },
  7. routes: [
  8. // 首页
  9. {
  10. path: '/',
  11. component:Index
  12. },
  13. ]
  14. }

2、根实例中必须加入router配置

  1. /**
  2. * 创建根实例
  3. */
  4. var vue = new Vue({
  5. el: "#app",
  6. // 引入路由实例
  7. router,
  8. render: h => h(App)
  9. });
版权声明:本站文章除特别声明外,均采用署名-非商业性使用-禁止演绎 4.0 国际 许可协议,如需转载,请注明出处