swal的几种用法

1,弹出提示框,点击确认,进行下一步操作

swal({
    title: "操作提示",
    text: `是否删除名为“${query}”的反例?`,
    type: "warning",
    showCancelButton: true,
    confirmButtonColor: "#4D9BFF",
    cancelButtonText: "取消",
    confirmButtonText: "是的,确定删除!",
    closeOnConfirm: true,
    timer: 200
     }, function (isConfirm) {
        if (isConfirm) {
            $.ajax({
            type: 'DELETE',
            url: now_url + '/knowledge/mark/fanli/',
            data: JSON.stringify({fanli_id: fanli_id}),
            contentType: 'application/json;charset=UTF-8',
            dataType: "json",
            crossDomain: true,
            xhrFields: {
                  withCredentials: true
                },
            success: function success(response) {
                  if (response.code === 0) {
                      $.message('删除反例成功');
                      getFanliResult(collectionSearchCondition(1), 1);
                    } 
                  else if (response.code === 1) {
                      setTimeout(function () {  // 此处加上定时,否则会出现闪现,一起消失的现象
                          swal({
                            title: "操作提示",
                            text: response.msg,
                            type: "warning",
                            confirmButtonColor: "#4D9BFF",
                            confirmButtonText: "确定",
                            closeOnConfirm: true
                          })}, 100);
                        }
                    },
            error: function error(err) {
                  console.log(err);
                  }
            });
            }
        else {}
  });

2,仅弹出提示框

swal({
    title: "操作提示",
    text: "请选择一个实例",
    type: "warning",
    confirmButtonColor: "#4D9BFF",
    confirmButtonText: "确定",
    closeOnConfirm: true
})

3,仅弹出提示框,简单写法

swal("导出失败", "no permission", "error");
swal("操作提示", "配置下发成功!", "success");
swal("配置下发失败", response.msg, "warning");

你可能感兴趣的:(swal的几种用法)