小编ris*_*shi的帖子

处理expo React Native中的多个复选框

我希望能够在我的 expo React 本机应用程序中添加多个复选框。我在下面提供相关代码。我的类中有一个数组,其中包含有关复选框的详细信息,它有一个 id、必须旁边的文本以及检查该复选框是否被选中的检查。


我的代码


class App extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            count: 0,
            inputTxt: "",
            checks: [
                {id: 1, txt: "first check", isChecked: false },
                {id: 2, txt: "second check", isChecked: false }
            ]
        };
    }
    render() {
        return (
            <View style={styles.container}>
                <Text style={styles.text}>Details Screen</Text>
                <View>
                    <View style={styles.checkboxContainer}>
                        <CheckBox/>
                         {/* Add all the checkboxes from my this.state.checks array here */}
                        <Text style={styles.label}>Do you like React Native?</Text>
                    </View>
                </View>
              [...]
            </View>
        );
    }
}
Run Code Online (Sandbox Code Playgroud)

javascript checkbox reactjs react-native expo

3
推荐指数
1
解决办法
1万
查看次数

标签 统计

checkbox ×1

expo ×1

javascript ×1

react-native ×1

reactjs ×1