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')
版权声明:本文为weixin_44152684原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。