vue3路由默认配置文件内容(index.js)
import {createRouter, createWebHistory} from 'vue-router'
const routes = [
{
name: 'sam',
path: '/sam',
component: () => import('@/view/sam')
},
{
name: 'app',
path: '/app',
component: () => import('@/view/app')
},
];
const router = createRouter({
history: createWebHistory(), //路由模式
routes
})
export default router //导出
在main.js中引入
import { createApp } from 'vue'
import App from './App.vue'
import router from './router/index'
//注意use要在mount之前
createApp(App).use(router).mount('#app')