vue中router正确但子页面没办法出现东西,没有报错。
import Vue from 'vue'
import VueRouter from 'vue-router'
import accoutPage from '../views/accout/wallet/accoutPage.vue'
import a from '../src/views/accout/a.vue'
import b from '../src/views/accout/b.vue'
import c from '../src/views/accout/c.vue'
Vue.use(VueRouter)
const routes = [
{
path: '/accoutPage',
name: 'accoutPage',
component: accoutPage,
redirect:
{ name: 'a' },
children:
[
{
path: '/account/wallet',
name: '/account/wallet',
redirect: '/account/wallet/a',
component: a,
meta: {
title: '页面a'
}
},
{
path: '/account/wallet',
name: '/account/wallet',
redirect: '/account/wallet/b',
component: b,
meta: {
title: '页面B'
}
},
{
path: 'c',
name: 'c',
component: c,
meta: {
title: '页面c'
}
}
]
}
]
const router = new VueRouter({
routes
})
export default router
检查一下router-view写的地方是否正确
页面a跟b的path重复了
你将a和b路由重定向到 /account/wallet/a 和 /account/wallet/b
这两个路由并没有定义
你需要定义这两个重定向到的路由
{
path: '/account/wallet/a',
name: '/account/wallet/a',
component: a,
meta: {
title: '页面a'
}
},
{
path: '/account/wallet/b',
name: '/account/wallet/b',
component: b,
meta: {
title: '页面b'
}
},