配置路由报错

来源:3-3 vue-router

小蜗牛linner

2018-08-28 23:40:26


import Vue from 'vue';

import Router from 'vue-router';

// import Home from 'pages/home';

// import Category from 'pages/category';

// import Cart from 'pages/cart';

// import Personal from 'pages/personal';

// import Search from 'pages/search';

import Product from 'pages/product';


Vue.use(Router);

const routes=[

{

name:'home',

path:'/home',

component:()=>import('pages/home'),

children:[

{

name:'home-product',

path:'product/:id',

component:()=>import('pages/product')

}

]

},

{

name:'category',

path:'/category',

component:()=>import('pages/category')

},

{

name:'cart',

path:'/cart',

ccomponent:()=>import('pages/cart')

},

{

name:'personal',

path:'/personal',

component:()=>import('pages/personal')

},

{

name:'search',

path:'/search',

component:()=>import('pages/search')

},

{

name:'*',

redirect:'/home'

}

];

export default new Router({

  routes

});




vue-router.esm.js?fe87:10 Uncaught Error: [vue-router] "path" is required in a route configuration.

    at assert (vue-router.esm.js?fe87:10)

    at addRouteRecord (vue-router.esm.js?fe87:1146)

    at eval (vue-router.esm.js?fe87:1116)

    at Array.forEach (<anonymous>)

    at createRouteMap (vue-router.esm.js?fe87:1115)

    at createMatcher (vue-router.esm.js?fe87:1336)

    at new VueRouter (vue-router.esm.js?fe87:2430)

    at eval (index.js?3672:49)

    at Object../src/router/index.js (app.js:3589)

    at __webpack_require__ (app.js:708)


写回答

1回答

Miss路

2018-08-29

从你的代码中,和报错信息中看出了一些问题,首先报错信息提示说path是不许要写的,

在你的配置文件 中,这里要写成path,如下图,name换成path试试看。
http://img.mukewang.com/climg/5b8615a4000190d803670188.jpg

如果帮助到了你,欢迎采纳!

0

0 学习 · 3299 问题

查看课程