- http://www.jianshu.com/p/2733fb656083
- 1,绑定this,不传参
export default class Nearby extends Component{ static defaultProps={ name:'111' } render(){ return( <View style={styles.containerStyle}> <Text style={styles.textStyle} onPress={this.Click}>Home</Text> </View> ); } Click = () =>{ console.log(this.props.name) } }
- 2,绑定this,传参
export default class Nearby extends Component{ static defaultProps={ name:'111' } render(){ return( <View style={styles.containerStyle}> <Text style={styles.textStyle} onPress={()=>this.Click('222')}>Home</Text> </View> ); } Click = (name) =>{ console.log(this.props.name) } }
React-Native的绑定this
最新推荐文章于 2021-01-04 22:37:39 发布