1. 程式人生 > >使用Layer Confirm彈窗沒有點選確定按鈕就執行了確定方法

使用Layer Confirm彈窗沒有點選確定按鈕就執行了確定方法

使用LayerConfirm方法確定回撥方法不能傳參。如果傳參了,會直接執行不會等到點選確定在執行

Layer.confirm("確定執行此操作?", "執行該操作將不能撤回", "確定", AuditRemit, "取消", null);

confirm: function (content, title, sureText, sureFunction, closeText, closeFunction) {
  title = title || "";
  layer.confirm(
    content, { title: title, icon: 3, btn: [sureText, closeText], resize: false },
    function (index) {//確定回撥
    if (sureFunction) {
      sureFunction();
    }
    layer.close(index);
  }, function (index) {//cancel回撥
  if (closeFunction) {
    closeFunction();
  }
    layer.close(index);
  });
},