reactjs - 在本机反应中根据某些条件启用道具?
问题描述
我想为原生基本按钮应用带有边框的道具,如果menuIndex == menus.house
.
<Button bordered>
<Text uppercase={false}>House</Text>
</Button>
这是我尝试过的,
<Button {menuIndex == menus.house? '' : bordered}>
<Text uppercase={false} style={styles.menuTextButtonActive}>
House
</Text>
</Button>
解决方案
<Button bordered>
...
</Button>
可以理解如下
<Button bordered={true}>
...
</Button>
因此,您可以执行如下布尔表达式
<Button bordered={menuIndex == menus.house}>
<Text uppercase={false} style={styles.menuTextButtonActive}>
House
</Text>
</Button>
推荐阅读
- php - 交货报价 404 Not Found
- html - 如何从 textarea 元素中删除调整大小的角?
- ajax - 属性“ScriptServiceAttribute”无法应用于“MethodName”,因为该属性在此声明类型上无效
- c# - 如何从类中添加另一个输入
- php - 如何按最小值计算产品总价。Woocommerce中的数量订单?
- java - 将 ImageIcon 添加到 JLabel
- javascript - 组内的导入源必须按字母顺序排列 (TS)
- javascript - Google Treemap:想要将节点的颜色设置为红色、绿色和琥珀色
- r - 从 Map 中的列表中获取对象的名称
- specman - Specman e:“keep type .. is a”无法细化字段的类型