更新时间:2022-01-17 22:28:21
我想你忘记在Button
中bind
event
,使用这部分:
I think you forgot to bind
the event
in Button
, Use this part:
<Button
onPress = {this.submit.bind(this)}
title = {this.state.buttonvalue}
color = '#FF7323'>
</Button>
你可以在constructor
中定义binding
:
constructor(props) {
super(props);
this.state = {
remarkstext: 'Remarks' ,
buttonvalue: 'Submit' ,
selected1: '--Select--',
selected2: '--Select--',
color: 'red',
mode: Picker.MODE_DIALOG,
};
this.submit = this.submit.bind(this);
}
Update- fetch
调用模式:
fetch(url)
.then(response => response.json())
.then(response => {
console.log(response);
})
.catch( error =>
console.log('There has been a problem with your fetch operation: ' + error.message);
)
您需要以这种方式捕获异常
和错误.
You need to Catch the exceptions
and errors in this way.