想实现的效果是如果自己输入地址:localhost:8080/detail/detail 可以跳转至 localhost:8080/detail/detailInfo,现在地址可以,但是内容还是localhost:8080/detail/detail下的内容
路径:
import detialPage from '../components/detial/detial'
import detialInfo from '../components/detial/detialInfo'
{
path:'/detial',
component: detialPage,
children:[
{
path:'detialInfo',
component:detialInfo,
meta: {
requiresAuth: true
}
}
],
redirect:'/detial/detialInfo',
meta: {
requiresAuth: true
}
}
全部配置
import Vue from 'vue'
import Router from 'vue-router'
import Index from '../components/index'
import Classify from '../components/classify'
import Cart from '../components/cart'
import Center from '../components/center'
import Welcome from '../components/welcome'
import Login from '../components/login'
import Common from '../common'
import father from '../components/father'
import detialPage from '../components/detial/detial'
import detialInfo from '../components/detial/detialInfo'
Vue.use(Router)
export default new Router({
mode: 'history',
routes: [
{
path: '/f',
component: father // 登录页面
},
{
path: '/login',
component: Login // 登录页面
},
{
path: '/welcome',
component: Welcome // 登录页面
},
{
path: '',
component: Common, // 原来的 App.vue
children: [
{
path:'/detial',
component: detialPage,
children:[
{
path:'detialInfo',
component:detialInfo,
meta: {
requiresAuth: true
}
}
],
redirect:'/detial/detialInfo',
meta: {
requiresAuth: true
}
},
{
path: '/',
component: Index,
meta: {
requiresAuth: true
}
},
{
path: '/classify',
component: Classify,
meta: {
requiresAuth: true
}
},
{
path: '/cart',
component: Cart,
meta: {
requiresAuth: true
}
},
{
path: '/center',
component: Center,
meta: {
requiresAuth: true
}
}
]
}
]
})