【发布时间】:2021-06-07 11:08:03
【问题描述】:
我有以下代码;
{
this.state.isWPAEnterpriseInstalled && !this.state.passpoint && !this.state.expanded || this.state.isWPAEnterpriseInstalled && !this.state.expanded && this.state.isEnterprise && <TouchableOpacity style={!this.state.expanded ? [styles.button, { backgroundColor: this.state.primary_color }] : [styles.expandedButton, { backgroundColor: this.state.primary_color }]}
activeOpacity={0} onPress={this.removeConfigEnterprise}>
<Text allowFontScaling={false} style={styles.button_text}>Remove WPA </Text>
</TouchableOpacity>
}
我遇到的问题是条件渲染线;
this.state.isWPAEnterpriseInstalled && !this.state.passpoint && !this.state.expanded || this.state.isWPAEnterpriseInstalled && !this.state.expanded && this.state.isEnterprise &&
就像它只识别 OR 运算符之间的这些条件之一,即首先放置的那个。有条件渲染的 React 中是否有 OR (||) 运算符不可用?
如果是这样,我该如何实现以下目标?例如基于 2 OR 条件渲染。
IF ABC AND GH AND ER OR DEF AND FGH AND TYU then display button
编辑
已解决。上面的代码有效,但在我期望不同值的状态集之一不匹配。
【问题讨论】:
标签: android react-native conditional-rendering