第三章 组件

2017-10-02  本文已影响0人  简人CC

1.Text

2.TextInput

<Image source={require('./images/home_selected.png')} style={styles.image} />

未成功

  export default class AwesomeProject extends Component {
  constructor(props) {
    super(props);
    var ds = new ListView.DataSource({ rowHasChanged: (r1, r2) => r1 !== r2 });
    this.state = {
      dataSource: ds.cloneWithRows(this.genRows()),
    };
  }

  genRows() {
    var dataBlob = []
    for(var i = 0 ; i < 20 ; i++) {
      var pressedText = 'item' + i;
      dataBlob.push(pressedText)
    }

    return dataBlob
  }
  render() {
    return (
      <ListView
        dataSource={this.state.dataSource}
        renderRow={(rowData) => <Text>{rowData}</Text>}
      />
    );
  }
}
   export default class AwesomeProject extends Component {
 constructor(props) {
   super(props)
   this.state = {
     switchState1: true
   }
 }
 render() {
   return (
     <View>
       <Switch onValueChange={this.onValueChange.bind(this)} value={this.state.switchState1} />
     </View>
   );
 }
 
 onValueChange(value) {
   this.setState({
     switchState1: value
   })

   alert(this.state.switchState1)
 }
}

Event

上一篇下一篇

猜你喜欢

热点阅读