【发布时间】:2021-07-11 22:17:06
【问题描述】:
我正在学习 Onsen-ui React,但重置状态的按钮不起作用。
看下面一个简单的测试用例
´´´
class MyApp extends Component {
constructor(props) {
super(props);
this.state = { myVal: 123 };
}
clickTest() {
this.setState({ myVal:456 });
}
render() {
return (
<Page>
<div id="test">{this.state.myVal}</div>
<ons-button onClick="clickTest()">test</ons-button>
<ons-button onPress={() => { this.setState({ myVal:999}); }}>test</ons-button>
</Page>
);
}
}
My kidney for a good answer ;-) its bugging me for days
I want to change the state of myVal with ons-button and react
【问题讨论】: