Window.location Javascript JS 重定向

Window.location Javascript JS Redirect

我有这个:

                setTimeout(function () {
              $.dialog({
                title: 'Existing user',
                content: "This account is already registered on our system. If you are the real owner, contact us!",
                icon: 'fas fa-user',
                theme: 'modern',
                animation: 'scale',
                type: 'red',
                draggable: false,
                closeIcon: function(){
                              window.location="/dashboard";
                          },
              });
            }, 200);

我需要在 he/she 单击 "closeIcon" 5 秒后重定向用户。问题是,如果我使用这个对话框永远不会显示:

                    closeIcon: setTimeout(function () {
                              window.location="/dashboard";
                          }, 5000);
              });

我该怎么办?

谢谢!

编辑:

我也试过这个,但是不行:

                function () {
              $.dialog({
                title: 'Existing user',
                content: "This account is already registered on our system. If you are the real owner, contact us!",
                icon: 'fas fa-user',
                theme: 'modern',
                animation: 'scale',
                type: 'red',
                draggable: false,
                closeIcon: setTimeout(function () {
                              window.location="/dashboard";
                          }, 5000);
              });
            }

closeIcon: function () {
  setTimeout(function () {
      window.location="/dashboard";
  }, 5000);
}
改为这样做。

问题是 setTimeout returns a positive integer, but the closeIcon expects a function. Using an arrow function (ES6) 附上计时器应该可以解决问题。您也可以使用常规函数。

setTimeout(function () {
    $.dialog({
        title: 'Existing user',
        content: "This account is already registered on our system. If you are the real owner, contact us!",
        icon: 'fas fa-user',
        theme: 'modern',
        animation: 'scale',
        type: 'red',
        draggable: false,
        closeIcon: ()=> {
            setTimeout(()=>window.location = "/dashboard",2000);
        },
    });
}, 200);

有没有办法在多语言网站上实现这一点,以便“/dashboard”重定向到网站上的每种特定语言?