uni-helper / vite-plugin-uni-pages

为 Vite 下的 uni-app 提供基于文件系统的路由
https://uni-helper.js.org/vite-plugin-uni-pages
MIT License
104 stars 15 forks source link

怎么根据不同平台生成不同的路由 #156

Open 54lianxi opened 4 months ago

54lianxi commented 4 months ago

描述问题

需要根据不同的平台生成不同的路由,比如小程序和h5的路由是不同的,但是他们有一部分路由是一样的

复现

image image image image image 以上是我使用过的方法,没一个奏效的,但是我看官方里面是说可以使用的

系统信息

image

使用的包管理器

pnpm

核对

54lianxi commented 4 months ago

image 系统信息在这

sunpm commented 4 months ago

pages.config.ts 中添加条件编译也没效果

KeJunMao commented 4 months ago

如果你使用自动扫描的话,尝试在 vite.config.ts 中使用 onBeforeWriteFile 这个钩子 如果你不使用自动扫描的话,尝试 https://github.com/uni-helper/uni-env ,并直接使用 if else

我们似乎需要更好的方式~

如果你愿意尝鲜,https://github.com/uni-helper/vite-plugin-uni-platform 这个库应该对你有用

AursorDev commented 1 week ago

坑死人了啊

AursorDev commented 1 week ago

如果你使用自动扫描的话,尝试在 vite.config.ts 中使用 onBeforeWriteFile 这个钩子 如果你不使用自动扫描的话,尝试 https://github.com/uni-helper/uni-env ,并直接使用 if else

我们似乎需要更好的方式~

如果你愿意尝鲜,https://github.com/uni-helper/vite-plugin-uni-platform 这个库应该对你有用

这个也没用,都是bug