我的错误代码
缺了前面的方法
const routes = [
{ path: '/',
component: Home }
},
]
参考做法:router官网
https://next.router.vuejs.org/guide/#javascript
正确的
const router = createRouter({
history: createWebHashHistory(), // hash模式:createWebHashHistory,history模式:createWebHistory
routes: [
{
path: '/',
redirect: '/home'
},
{
path: '/home',
name: 'home',
component: () => import(/* webpackChunkName: "home" */ '@/views/Home.vue'),
meta: {
index: 1
}
},