自动注册路由
This commit is contained in:
@@ -1,20 +1,33 @@
|
||||
import { createRouter,createWebHashHistory, RouteRecord} from "vue-router";
|
||||
import {zujian} from "../page/install"
|
||||
interface routesgeshi{
|
||||
path:String,
|
||||
name:String,
|
||||
component:object
|
||||
}
|
||||
import { createRouter,createWebHashHistory} from "vue-router";
|
||||
let routes1 :Array<any>=[]
|
||||
const files:any = import.meta.globEager('/src/page/*.vue')
|
||||
console.log(files)
|
||||
// for(let i in files){
|
||||
// console.log(files[i].default)
|
||||
// }
|
||||
|
||||
for(let i in files){
|
||||
if(files.hasOwnProperty(i)){
|
||||
console.log(i)
|
||||
routes1.push({
|
||||
path:"/"+files[i].default.name,
|
||||
name:files[i].default.name,
|
||||
component:files[i].default
|
||||
})
|
||||
}
|
||||
|
||||
for(let i in zujian){
|
||||
console.log(i)
|
||||
routes1.push({
|
||||
path:"/"+zujian[i].name,
|
||||
name:zujian[i].name,
|
||||
component:zujian[i]
|
||||
})
|
||||
}
|
||||
|
||||
// for(let i in zujian){
|
||||
// console.log(i)
|
||||
// routes1.push({
|
||||
// path:"/"+zujian[i].name,
|
||||
// name:zujian[i].name,
|
||||
// component:zujian[i]
|
||||
// })
|
||||
// }
|
||||
|
||||
|
||||
// console.log(routes1)
|
||||
// console.log(zujian, typeof zujian)
|
||||
// const routes = [
|
||||
|
||||
Reference in New Issue
Block a user