我正试图提醒this.state.name,但不幸的是,它显示无法读取属性名称错误
export default class SignUp extends Component {
constructor(props) {
super(props);
this.state = {
Pro: [],
name:'g',
phone:'',
pass:'',
}}
registerUser(){
alert(this.state.name)}
render(){
return(
<TouchableOpacity onPress={this.registerUser} style={styles.buttonContainer}
onPress={this.registerUser}>})}
答案 0 :(得分:0)
执行此操作:
registerUser =()=>{
alert(this.state.name)}
和<TouchableOpacity>
中的
onPress={()=>{this.registerUser()}}
它将起作用!