09
03/23
vue3+vite3实现路由自动化
import {createRouter, createWebHashHistory} from 'vue-router' const modules = import.meta.glob('/src/pages/**/index.js'); console.log(modules); const routes = []; let components = []; Object.keys(modules).forEach(key => { let component = modules[key]; components.push(component()); let name = key.split('pages/')[1].split('/')[0].toLowerCase(); let path = "/" + name; if (name === 'index') { path = "/"; } ...