REACTJS重定向+ 5秒超时

问题描述

我对reactjs还是很陌生,无法解决问题。我正在尝试建立一个5秒后重定向的网页,但似乎无法弄清楚该怎么做。如果有人对我有任何提示,我可以找到解决方法,将不胜感激。

谢谢:)

解决方法

您可以使用纯JavaScript来完成此操作。看起来像这样:

setTimeout(function() {
  window.location.replace('some-url');
},5000);

取决于何时触发,您可以将其放在某个组件的"lifecycle method"中,甚至可以简单地将其添加到JS文件的开头或'DOMContentLoaded' event中。

,

不确定您的用例,但是您可以简单地使用git checkout develop git pull -p git checkout feature_branch git merge develop git push origin feature_branch

https://www.w3schools.com/jsref/met_win_settimeout.asp

,您想在setTimeout中使用它。

https://reactjs.org/docs/state-and-lifecycle.html

上了解有关生命周期的更多信息

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...