请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

无法自动重定向

tab组件切换,下面视图会更换,但是从根目录打开不会自动跳转到recommend组件,下面视图一片空白。已配置

{
    path: '/',
    redirect: '/recommend'
  },
  {
    path: '/recommend',
    name: 'recommend',
    component: Recommend
  },

正在回答 回答被采纳积分+3

1回答

ustbhuangyi 2022-10-30 23:17:52

看一下初始化的 router 代码

0 回复 有任何疑惑可以回复我~
  • 提问者 拈花一笑T #1
    是src/router/index.js代码吗?
    
    import { createRouter, createWebHashHistory } from 'vue-router'
    import Recommend from '@/views/recommend'
    import Singer from '@/views/singer'
    import Search from '@/views/search'
    import TopList from '@/views/top-list'
    const routes = [
      {
        path: '/',
        redirect: '/recommend'
      },
      {
        path: '/recommend',
        name: 'recommend',
        component: Recommend
      },
      {
        path: '/singer',
        name: 'singer',
        component: Singer
      },
      {
        path: '/search',
        name: 'search',
        component: Search
      },
      {
        path: '/top-list',
        name: 'top-list',
        component: TopList
      },
    ]
    
    const router = createRouter({
      history: createWebHashHistory(process.env.BASE_URL),
      routes
    })
    
    export default router
    回复 有任何疑惑可以回复我~ 2022-11-03 10:17:15
问题已解决,确定采纳
还有疑问,暂不采纳
意见反馈 帮助中心 APP下载
官方微信