6.重定向
-- 未经授权禁止转载 --
demo\src\router\index.js
    import { createRouter, createWebHashHistory, createWebHistory } from "vue-router"

    const routes = [
        {
            //可选参数 name? 表示该参数不是必需的
            path: "/userHistory/:id/name/:name?", // http://localhost:5173/userHistory/007/name
            name: "history", // 定义路由名称
            component: () => import("@/views/user.vue")
        },
        {
            path: "/vip", 
            component: () => import("@/views/vip.vue"),
            children: [ // 子路由
                {
                    path: '', // 默认页 http://localhost:5173/vip
                    component: import("@/views/vip/default.vue")
                },
                {
                    path: 'order', // 会员订单 http://localhost:5173/vip/order
                    component: import("@/views/vip/order.vue")
                },
                {
                    path: 'info', // 会员资料 http://localhost:5173/vip/info
                    component: import("@/views/vip/info.vue")
                }
            ]
        },
        {
            path: "/svip", // http://localhost:5173/svip
            //redirect: "/vip" // 重定向
            redirect: { name: 'history', params: { id: '100', name: 'David' } }
        },
    ]

    const router = createRouter({
        // 使用url的#符号之后的部分模拟url路径的变化,因为不会触发页面刷新,所以不需要服务端支持
        // history: createWebHashHistory(), 
        history: createWebHistory(),
        routes
    })

    export default router