Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

页面配置.config.js能支持多端 #12755

Closed
li-jun opened this issue Nov 2, 2022 · 2 comments
Closed

页面配置.config.js能支持多端 #12755

li-jun opened this issue Nov 2, 2022 · 2 comments
Labels
E-easy Helper Wanted - Easy enhancement New feature or request

Comments

@li-jun
Copy link

li-jun commented Nov 2, 2022

这个特性解决了什么问题?

同一个页面的配置,在不同小程序平台上某些配置是不一样的,比如导航栏风格:
微信、支付宝: navigationStyle: 'custom'
抖音: navigationStyle: 'default'

这个 API 长什么样?

1).config.js文件能支持多端。
2)或者definePageConfig定义的页面配置对象能支持使用变量。

@taro-bot2 taro-bot2 bot added the enhancement New feature or request label Nov 2, 2022
@li-jun
Copy link
Author

li-jun commented Nov 2, 2022

已经找到解决方案了,虽然definePageConfig定义的页面配置对象不能使用变量,但取值时可以使用process.env.TARO_ENV !== 'tt'判断。比如:
export default definePageConfig({
navigationStyle: process.env.TARO_ENV !== 'tt' ? 'custom' : 'default',
transparentTitle: "auto"
})

但其实还是不够灵活,如果条件更复杂的话可读性就差很多了。

@TheKonka
Copy link
Member

TheKonka commented Nov 24, 2022

image

https://docs.taro.zone/docs/next/envs#%E5%A4%9A%E7%AB%AF%E7%BB%84%E4%BB%B6

你可以同时建个 tt.config.ts 给抖音小程序使用

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E-easy Helper Wanted - Easy enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants