无法自动重定向

来源:2-6 【讨论题】获取轮播图接口数据

拈花一笑T

2022-10-26

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

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

1回答

ustbhuangyi

2022-10-30

看一下初始化的 router 代码

0
1
拈花一笑T
是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
共1条回复

Vue3开发企业级音乐Web App 明星讲师带你学大厂代码

慕课网明星讲师黄轶深度讲解 Vue3.0 ,提升的不止是Vue代码能力

2223 学习 · 1002 问题

查看课程