import {createElement, Component} from 'weex-rx';
import { View, Text} from 'nuke-components';
import { Checkbox,Button } from 'nuke';
import {mount} from 'nuke-mounter';
function unique(array){
var n = [];
for(var i = 0;i < array.length; i++){
if(n.indexOf(array[i]) == -1) n.push(array[i]);
}
return n;
}
let App = class NukeDemoIndex extends Component {
constructor() {
super();
this.state = {
dataSource:[
{value: 'apple', label: '苹果'},
{value: 'pear', label: '梨', disabled: true},
{value: 'orange', label: '橘子'}
],
value:['apple']
}
}
changeData(){
let newSource = [
{value: 'apple', label: '苹果',disabled: true},
{value: 'pear', label: '梨',disabled: true},
{value: 'orange', label: '橘子',disabled: true}
];
this.setState({
dataSource:newSource
})
}
onChange(value){
this.setState({
value:value
})
console.log(this.state.value)
}
render() {
return (
<View>
<Button onPress={this.changeData.bind(this)}>点击切换datasource</Button>
<Checkbox.Group value={this.state.value} onChange={ this.onChange.bind(this) }size="small" dataSource={ this.state.dataSource }></Checkbox.Group>
</View>
);
}
}
mount(<App/>, mountNode);