采纳答案成功!
向帮助你的同学说点啥吧!感谢那些助人为乐的人
tab组件切换,下面视图会更换,但是从根目录打开不会自动跳转到recommend组件,下面视图一片空白。已配置
{ path: '/', redirect: '/recommend' }, { path: '/recommend', name: 'recommend', component: Recommend },
看一下初始化的 router 代码
是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
登录后可查看更多问答,登录/注册
慕课网明星讲师黄轶深度讲解 Vue3.0 ,提升的不止是Vue代码能力
1.1k 3
459 23
2.8k 15
1.0k 14
1.2k 13