(Vue) 路由踩坑(一)

const routes = [
    {
        name: 'home',
        path: '/',
        component: Home,
        meta: {
            title: '首页'
        },
        redirect: '/welcome',
        children: [
            {
                name: 'welcome',
                path: '/welcome',
                meta: {
                    title: '欢迎页'
                },
                component: () => import('./../views/Welcome.vue'),
            },
            {
                name: 'user',
                path: 'user',
                meta: {
                    title: '用户管理'
                },
                component: () => import('./../views/Welcome.vue'),
                children: [
                    {
                        name: 'info',
                        path: 'info',
                        meta: {
                            title: '信息统计'
                        },
                        component: () => import('./../views/Welcome.vue'),
                    },
                ]
            },
        ]
    },
    {
        name: 'login',
        path: '/login',
        component: () => import('./../views/Login.vue'),
        meta: {
            title: '登录'
        },
    }
]

  子路由中的path不能加"/"不然路径会变成绝对路径 如 www.xxx.com/info

  如果想要 www.xxx.com/user/info 千万不能加"/"

 

上一篇:Vue SPA项目如何修改网站标题


下一篇:html中meta标签的用处