赞
踩
main.js
import { createApp } from 'vue'; import App from './App.vue'; import { createRouter, createWebHistory } from 'vue-router'; const views = import.meta.glob('./views/**/index.vue'); const routes = Object.keys(views).map((path) => { const name = path.match(/\.\/views\/(.*)\/index\.vue$/)[1]; return { path: `/${name}`, name, component: views[path], }; }); const router = createRouter({ history: createWebHistory(), routes, }); const app = createApp(App); app.use(router); app.mount('#app');
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。