【发布时间】:2020-01-09 22:32:28
【问题描述】:
我正在使用 NativeBase 和 React Native。
以这种方式创建的 NativeBase 按钮:
<Button warning>
<Text>Hello</Text>
</Button>
您可以使用不同的类型来代替 warning,例如 info 或 success。
现在,我想根据道具创建这些按钮并尝试执行以下操作:
<Button {this.props.type}>
<Text>Hello</Text>
</Button>
但我找不到办法,因为这个道具没有价值。
可以不带值传递props吗?
【问题讨论】:
-
<Button {...this.props}>可以帮助你,如果你可以解构 props 对象,即使 props 是空对象也可以正常工作 -
这个answer 可能会有所帮助
标签: reactjs react-native native-base