0.0.1 • Published 11 months ago
vite-plugin-routes-generator v0.0.1
vite-plugin-routes-generator
vite 插件,依照傳入的物件生成路由
Basic Usage
Code
import { generateRoutes } from "vite-plugin-routes-generator";
const routes = generateRoutes({
components: import.meta.glob(`../views/**\/*.vue`),
routeConfigs: import.meta.glob(`../views/**\/*.ts`, {
eager: true, //轉成模塊
import: "default", //取出模塊的default
}),
});
Views
| views/
---| about.vue
---| index.vue
---| index.ts
---| posts/
-----| [id].vue
---| news.vue
---| news/
-----| index.vue
-----| [id].vue
index.ts
import { defineRouteConfig } from "vite-plugin-routes-generator";
export default defineRouteConfig({
meta: {
pageTitle: "首頁",
},
//define your validate here
// validate: (to) => {
// return true;
// },
});
Generated Routes
[
{
"path": "/about",
"name": "about",
"children": []
},
{
"path": "",
"name": "index",
"children": [],
"meta": {
"pageTitle": "首頁"
}
},
{
"path": "/news",
"name": "news",
"children": [
{
"path": ":id",
"name": "news-id",
"children": []
},
{
"path": "",
"name": "news-index",
"children": []
}
],
"redirect": { // Auto redirect to children's index route
"name": "news-index"
}
},
{
"path": "/posts/:id",
"name": "posts-id",
"children": []
}
]
0.0.1
11 months ago
1.1.10
12 months ago
1.1.9
2 years ago
1.1.8
2 years ago
1.1.7
2 years ago
1.1.6
2 years ago
1.1.5
2 years ago
1.1.4
2 years ago
1.1.3
2 years ago
1.1.2
2 years ago
1.1.1
2 years ago
1.1.0
2 years ago
1.0.9
2 years ago
1.0.8
2 years ago
1.0.7
2 years ago
1.0.6
2 years ago
1.0.5
2 years ago
1.0.4
2 years ago
1.0.3
2 years ago
1.0.2
2 years ago
1.0.1
2 years ago
1.0.0
2 years ago