V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
qwertyzzz
V2EX  ›  Vue.js

为什么访问不到 Ground 组件啊

  •  
  •   qwertyzzz ·
    123 · 69 天前 · 762 次点击
    这是一个创建于 69 天前的主题,其中的信息可能已经有所发展或是发生改变。

    总是会跳到/equipment 是不是/这个导致的啊。。。没系统看 vue 都是面向 gpt

    const router = createRouter({
        history: createWebHashHistory(),
        routes: [
    
            {
                name:'Ground',
                path:'/ground',
                component: ()=>import('@/view/Ground.vue')
            },
            {
                name:'Index',
                path:'/equipment/:c?',
                component: ()=>import('@/view/Index.vue'),
                beforeEnter: (to, from, next) => {
                    if (!to.params.c) {
                        // 如果参数 c 未定义,设置默认值
                        next({ name: 'Index', params: { c: 'rackets' } });
                    } else {
                        next();
                    }
                }
            },
            {
                path: '/',
                component: ()=>import('@/view/Index.vue')
            }
        ]
    })
    
    5 条回复    2024-08-07 17:45:01 +08:00
    InternetExplorer
        1
    InternetExplorer  
       69 天前
    是访问 /ground 会跳转到 /equipment 么
    我猜你在 Ground.vue 里写了跳转到 /equipment 的逻辑,然后还无意中写出了执行这个逻辑的代码
    qwertyzzz
        2
    qwertyzzz  
    OP
       69 天前
    @InternetExplorer Ground.vue 里啥都没。。
    Eension
        3
    Eension  
       45 天前
    {
    path: '/',
    component: ()=>import('@/view/Index.vue')
    }
    改{
    path: '/',
    redirect: '/ground'
    }
    qwertyzzz
        4
    qwertyzzz  
    OP
       45 天前
    @Eension 其实是我访问地址错了 中间有个/#/ ,你怎么在翻我帖子
    Eension
        5
    Eension  
       43 天前
    @qwertyzzz 啊?没有就是在翻 vue ,忘了看日期
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   1550 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 17:03 · PVG 01:03 · LAX 10:03 · JFK 13:03
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.