Mah*_*our 7 javascript settimeout react-native
我的问题是setTimeout运行吗?about 5 seconds较早。例如,当我将其设置为时5 seconds,它将立即运行,但是当我在上时15 seconds,它将在10 seconds以后运行。
我什至调查了这个问题:React Native中的setTimeout,但是我仍然无法解决问题
changeNotify() {
let that = this;
console.log("before");
setTimeout(function () {
console.log("After");
that.setState({notifyModal: false})
}, 5000);
}
Run Code Online (Sandbox Code Playgroud)
并在渲染
<Button
title='change'
onPress={() => this.setState({notifyModal: true},()=>this.changeNotify())}
/>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
661 次 |
| 最近记录: |