将按钮链接到 SweetAlert 中的另一个页面

linking a button to another page in SweetAlert

我在使用 sweet alert 并且我有 2 个按钮;一个是取消按钮,另一个是继续按钮。我想 link 'continue' 按钮到另一个页面 'trial.php'。我该如何继续呢?下面是我试过的代码:

if(m <= 2){
  swal({
    title:"dataset file is: "+  ""+size2 +"Mb",
    text: "a cluster of 1 node will be required for processing",
    buttons: {
      cancel: true,
      confirm: "continue"
    }
  })

使用.then()查看按下按钮的值,如果值为"continue",使用window.location.href将用户重定向到另一个页面:

swal({
  title: "dataset file is: " + "" + size2 + "Mb",
  text: "a cluster of 1 node will be required for processing",
  buttons: {
    cancel: true,
    confirm: "continue"
  }
}).then((value) => {
  if (value === "continue") {
    window.location.href = "trial.php";
  }
});

swal({ title: "test", text: "testing", buttons: { cancel: true, confirm: "continue" } }).then((value) => { if (value) { window.location.href = "trial.php"; } });