第一种
const router = new VueRouter({
routes: [{
path: '/newSongs',
component: require('../views/NewSongs'),
alias: '/'
}, {
path: '/rank',
component: require('../views/Rank')
}, {
path: '*', redirect: '/'
}]
})
export default router
第二种
Vue.use(Router) | |
export default new Router({ | |
routes: [ | |
{path:'/',redirect:'/home'}, | |
{path:'/home',component: home,meta:{title:'淘宝网高仿版'}}, | |
{path:'/express',component: express,meta:{title:'物流'}}, | |
{path:'/myTaobao',component: myTaobao,meta:{title:'我的淘宝'}}, | |
{path:'/shopcart',name:'shopcart',component: shopCart,meta:{title:'购物车'}}, | |
{path:'/goodDetail',name:'goodDetail',component: goodDetail,meta:{title:'商品详情'}}, | |
{path:'/ratings',name:'ratings',component: moreRating} | |
] | |
}) |
第三种
Vue.use(VueRouter)
const router = new VueRouter({
routes: [{
path: '/',
component:resolve=>require(['@/views/NewSongs'],resolve)
}]
})
export default router