1 简单部分代码
export default class App extends Component<Props> {
render() {
return (
<View style={styles.container}>
<View style={styles.welcome}>
<Button onPress={this.showMsg}title='prees me showMsg'/>
<Button onPress={() => {this.showMessage()}}title='prees me showMessage'/>
</View>
</View>
);
}
//记得这里调用的时候不需要加上()
showMsg(){
alert("showMsg(){}");
}
//记得末尾加上分号,调用的时候也要加上()
showMessage = () => {
alert("showMessage = () => {}");
};
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
welcome: {
fontSize: 10,
textAlign: 'center',
margin: 30,
},
});