Sweetalert2的使用

2020-08-18  本文已影响0人  coderTG

替代alert的好插件

5种提示

实例

swal({
  title: '确定删除吗?', 
  text: '你将无法恢复它!', 
  type: 'warning',
  showCancelButton: true, 
  confirmButtonColor: '#3085d6',
  cancelButtonColor: '#d33',
  confirmButtonText: '确定删除!', 
  cancelButtonText: '取消删除!',
  confirmButtonClass: 'btn btn-success',
  cancelButtonClass: 'btn btn-danger',
  buttonsStyling: false
}).then(function() {
  swal(
    '已删除!',
    '你的文件已经被删除。',
    'success'
  ); 
}, function(dismiss) {
  // dismiss的值可以是'cancel', 'overlay',
  // 'close', 'timer'
  if (dismiss === 'cancel') {
    swal(
      '已取消!',
      '你的虚拟文件是安全的:)',
      'error'
    ); 
  } 
})

需要在swal 写成 swal.fire

实例都能调用了!

swal.fire({
        title: '请求提示?', 
        text: '请求出错,检测系统是否已登录,或者联系系统管理员!处理!', 
        type: "error",
        timer:2000
});

地址
github地址:https://github.com/t4t5/sweetalert

官方文档: https://sweetalert.js.org/docs/

中文:

http://mishengqiang.com/sweetalert/

http://mishengqiang.com/sweetalert/

http://www.sucaihuo.com/jquery/12/1241/demo/

文档中没有浏览器兼容提示,只能自己测试了

上一篇 下一篇

猜你喜欢

热点阅读