为什么按照提示配置了router,然后每个子路由都跳转到index了?

来源:4-8 路由封装

隽愉

2020-03-24

图片描述`import Vue from 'vue’
import Router from 'vue-router’
import Home from './pages/home’
import Index from './pages/index’
import Product from './pages/product’
import Detail from './pages/detail’
import Cart from './pages/cart’
import Order from './pages/order’
import OrderConfirm from './pages/orderConfirm’
import OrderList from './pages/orderList’
import OrderPay from ‘./pages/orderPay’

Vue.use(Router);

export default new Router({
routes:[
{
path: ‘/’,
name:‘home’,
component:Home,
redirect:’/index’,
children:[
{
path:’/index’,
name:‘index’,
component:Index,
},{
path:’/product/:id’,
name:‘product’,
component:Product,
},{
path:’/detail/:id’,
name:‘detail’,
component:Detail,
}
]
},
{
path:’/cart’,
name:‘cart’,
component:Cart,
},
{
path:’/order’,
name:‘order’,
component:Order,
children:[
{
path:’/list’,
name:‘order-list’,
component:OrderList,
},{
path:’/confirm’,
name:‘order-confirm’,
component:OrderConfirm,
},{
path:’/pay’,
name:‘order-pay’,
component:OrderPay,
}
]
}
]
});`

写回答

1回答

河畔一角

2020-03-25

购物车和详情都会跳转到首页吗??

0
4
河畔一角
回复
隽愉
路由本来就应该是/#/cart,这是hash路由。
2020-03-25
共4条回复

Vue全家桶实战 从零独立开发企业级电商系统

Vue全家桶构建企业级电商系统,真实服务端数据对接,高实用性

2560 学习 · 1307 问题

查看课程