我在router/index.js的路径配置如下:
const routes = [
{
//表示默认显示首页
//cli4路由设置的path中只有"/"的话 URI为空是就会自动重定向
path: '/',
name: 'Home',
component: Home,
//配置子路由
children: [
{
//子路由不需要加/
path: 'news',
name: 'news',
component: HomeNews,
},
{
path: 'message',
component: () => import(/* webpackChunkName: "about" */ '../components/HomeMessage.vue')
}
]
},
{
path: '/about',
name: 'About',
// route level code-splitting
// this generates a separate chunk (about.[hash].js) for this route
// which is lazy-loaded when the route is visited.
component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
},
{
path: '/user/:userID',
name: 'User',
component: User
}
]