【发布时间】:2020-10-25 06:16:44
【问题描述】:
我正在尝试为登录页面实施解决方案。当用户传递错误的登录名/密码时,我希望页面在 3 秒后重新加载。我试图用 2 个解决方案来做到这一点,但无法让它发挥作用。当凭据(else condition) 不匹配时,代码将在单击按钮后启动:
第一个想法:
...else{
this.comUser = 'WRONG LOGIN OR PASSWORD'
this.alert = ""
setTimeout(function() {
window.location = "I would like it to use the routing to a component instead of URL here"; }
,3000);
承诺的第二个想法:
const reloadDelay = () => {
reload = this.router.navigate(['/login']);
return new Promise((resolve, reject) => {
setTimeout(() => {
console.log("działa");
resolve(reload)
}, 4000);
});
};
感谢任何提示!
【问题讨论】:
-
在过去的美好时光里,我们会使用简单的Meta Refresh
标签: javascript angular promise timeout reload