vitjs / vit

🚀 React application framework inspired by UmiJS / 类 UmiJS 的 React 应用框架
MIT License
100 stars 7 forks source link

想请教动态路由怎麽设定 #10

Closed BLKsherry closed 1 year ago

BLKsherry commented 1 year ago

前辈们好,目前在实作使用到像这样的动态路由

{ path: '/process-pending/:id/detail', icon: 'FileSearch', name: '查询明细', component: './pages/ProcessPending/Detail/index.jsx', hideInMenu: true },

使用开发模式 vite 可正常执行,但执行 vite build 打包却会出现路径不合法的错误

error during build: Error: Illegal characters in path. at pathArg (C:\Users\BLKsherry\Desktop\Project\frontend\node_modules\mkdirp\lib\path-arg.js:20:27) at Function.mkdirpSync [as sync] (C:\Users\BLKsherry\Desktop\Project\frontend\node_modules\mkdirp\index.js:18:10) at Service.writeFile (C:\Users\BLKsherry\Desktop\Project\frontend\node_modules\@vitjs\core\dist\Service\index.js:49:26) at C:\Users\Sherry.Bing\Desktop\Project\Bothwell\bothwell\frontend\node_modules\@vitjs\vit\dist\preset\exportStatic.js:23:17 at Array.map (<anonymous>) at exportStatic (C:\Users\BLKsherry\Desktop\Project\frontend\node_modules\@vitjs\vit\dist\preset\exportStatic.js:18:12) at Object.closeBundle (C:\Users\BLKsherry\Desktop\Project\frontend\node_modules\@vitjs\vit\dist\vitApp.js:37:39) at file:///C:/Users/BLKsherry/Desktop/Project/frontend/node_modules/rollup/dist/es/shared/rollup.js:22748:40 at processTicksAndRejections (node:internal/process/task_queues:96:5) at async Promise.all (index 0) at async PluginDriver.hookParallel (file:///C:/Users/BLKsherry/Desktop/Project/frontend/node_modules/rollup/dist/es/shared/rollup.js:22676:9) at async Object.close (file:///C:/Users/BLKsherry/Desktop/Project/frontend/node_modules/rollup/dist/es/shared/rollup.js:23750:13) at async Promise.all (index 0) at async build (file:///C:/Users/BLKsherry/Desktop/Project/frontend/node_modules/vite/dist/node/chunks/dep-c842e491.js:46421:13) at async CAC.<anonymous> (file:///C:/Users/BLKsherry/Desktop/Project/frontend/node_modules/vite/dist/node/cli.js:756:9)

想请问应该怎麽设置呢?谢谢!

yunsii commented 1 year ago

有点奇怪,我下班抽个时间看看 😥

yunsii commented 1 year ago

突然想起来了,exportStatic 不能支持动态路由的。有了动态路由的话还需要服务端支持才能正常使用,这点你考虑清楚了吗?

BLKsherry commented 1 year ago

好的,我了解了😥 由于我开发上有这项需求,需要这项设定,想请问有甚么推荐的做法吗? 我自己尝试再嵌入 react-router-dom 处理动态路由,但无法成功和我 antd/pro-layout 的 Menu 模板配合,导入子区块内容 😕

yunsii commented 1 year ago

如果对路由没有严格要求的话可以用查询参数来处理

BLKsherry commented 1 year ago

好的,我先这样处理好了,谢谢🙏