react-native - react-native 中的条件复选框
问题描述
我想得到一点帮助。我试图创造一个条件。如果产品有库存;必须选中复选框。如果不是,它必须是空的。我一点一点地摸索,我迷失在我的代码中。你能给我一点帮助吗?
感谢您的帮助和时间。
这是代码的一部分(我知道条件根本不正确,这只是一些事情的开始):
export default class Products extends Component {
constructor(props) {
super(props);
this.state = {
checked: true,
stock : true,
}
};
...
<View style={{ flexDirection: 'row' }}>
<CheckBox
value={this.state.stock ? !this.state.checked}
//onValueChange={() => this.setState({ checked: !this.state.checked })}
/>
<Text style={{marginTop: 5}}>Stock</Text>
</View>
解决方案
试试这个
<View pointerEvents="none">
<CheckBox
value={this.state.stock}
//onValueChange={() => this.setState({ checked: !this.state.checked })}
/>
</View>
推荐阅读
- flutter - 有没有办法将 Flutter 版本“绑定”到源代码控制?
- python - 应用函数在熊猫中创建多列
- jenkins - 错误注入:public org.apache.maven.repository.internal.DefaultVersionResolver
- swift - 如何使用“上一个”和“下一个”按钮在单个 swift UI 上动态显示 JSON 数据?
- android - Genymotion 模拟器显示无法正确渲染
- forms - 如何根据表单响应生成带有文本部分的文档?
- regex - 正则表达式结合匹配与负前瞻
- python - 无法将忽略陈旧元素实现为ignore_exceptions
- python - 使用 Flask 和 wtform 实现 Python 日期时间增量
- angular - Angular 发布请求并导航到新组件