我有一个复选框列表,我想在单击按钮
后检查选中了哪个复选框有人可以帮助我吗?
答案 0 :(得分:0)
代码完成
import React, {Component} from 'react';
import { Platform, StyleSheet, Text, View,ScrollView} from 'react-native';
import Checkbox from 'react-native-custom-checkbox';
export default class App extends Component {
constructor(props){
super(props);
this.state = {
checked: false,
check:[]
};
}
_myFunction(value,name,checked){
console.log("Log: "+value,checked);
};
clickButton(){
}
render() {
let checkboxes = [];
for(let i=0; i < 5;i++){
checkboxes.push(
<View>
<Checkbox
name='checkbox2'
checked={false}
size={30}
style={{backgroundColor: '#f2f2f2', color:'blue', borderRadius: 5}}
onChange={(name, checked) => this._myFunction(name,i, checked)}/>
</View>
);
}
return (
<View>
<Button onPress={()=>this.clickButton()}></Button>
{checkboxes}
</View>
);
}
}