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

fix(template): prevent default values from overriding props #17167

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

erweixin
Copy link

这个 PR 做了什么? (简要描述所做更改)

当默认值为 true 时,props value 设置为 false 不会生效

原代码类似:

const props = props.value || true

更改为

const props = props.value !==  undefined ? props.value : true

没有使用 ?? 是因为小程序暂时不支持,使用需要项目转为 es5。

const props = props.value ?? true

这个 PR 是什么类型? (至少选择一个)

这个 PR 涉及以下平台:

  • 所有小程序
  • 微信小程序
  • 支付宝小程序
  • 百度小程序
  • 字节跳动小程序
  • QQ 轻应用
  • 京东小程序
  • 快应用平台(QuickApp)
  • Web 平台(H5)
  • 移动端(React-Native)
  • 鸿蒙(harmony)

@erweixin
Copy link
Author

之前不会走到这个逻辑分支是因为前面有个 isBooleanStringLiteral 判断,使用 'true''false', video 的默认 props 改成了 !0'!1'。所以更改 isBooleanStringLiteral 的判断逻辑也能解决。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] Video 组件的 controls 等属性无效 Taro 4.0.7 Video 无法控制 controls 不展示
1 participant