配置路由报错

配置路由报错


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

登陆购买课程后可参与讨论,去登陆

1回答
Miss路 2018-08-29 11:41:24

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

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

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

问题已解决,确定采纳
还有疑问,暂不采纳

恭喜解决一个难题,获得1积分~

来为老师/同学的回答评分吧

0 星
热门框架Vue开发WebApp 18版
  • 参与学习           人
  • 提交作业       209    份
  • 解答问题       3299    个

本路径是通过ES6基础知识、运用Zepto、Swiper、fullPag等移动端常用工具包、以及当下流行框架Vue,结合多个实战案例,还原真实开发场景,最终实现手机端购物商城网页开发。

了解课程
请稍等 ...
意见反馈 帮助中心 APP下载
官方微信

在线咨询

领取优惠

免费试听

领取大纲

扫描二维码,添加
你的专属老师