vue右击弹框跟随鼠标位置_一个零依赖的漂亮的JavaScript弹框插件——sweetalert2

介绍

sweetalert2是一个漂亮的、响应式、可定制的替代JAVASCRIPT原生的弹出框插件。sweetalert2相比sweetalert更加强大,但它不是sweetalert的扩展,它是一个全新的插件,且支持三大流行前端框架React、Vue、Angular。

398d3d7cd6cf79d30780d3a61706f6c0.png

Github和官网

https://github.com/sweetalert2/sweetalert2

https://sweetalert2.github.io/

安装

提供了很多安装方式

  • 使用npm安装
npm install --save sweetalert2
  • 使用cdn

注意:如果想要兼容IE11,还得引入polyfill.js

模块化用法

// ES6 Modules or TypeScriptimport Swal from 'sweetalert2'// CommonJSconst Swal = require('sweetalert2')

示例

  • 最基本的信息弹出框
Swal.fire('基本信息弹框')
1535d340df166b01e579153bad66dbb5.png
  • 标题下包含文字
Swal.fire( '标题下有文字', '标题下的文字?', 'question' )
f976b82c14eb58286329a80feb68b736.png
  • 底部文字
Swal.fire({ type: 'error', title: '标题', text: '出错啦!', footer: '为什么会出错?' })
b84932441865795225644ce85062fd26.png
  • 自定义html
Swal.fire({ title: 'HTML 示例', type: 'info', html: '你可以使用自定义的html百度一下', showCloseButton: true, showCancelButton: true, focusConfirm: false, confirmButtonText: '好的', confirmButtonAriaLabel: '看起来不错', cancelButtonText: '取消', cancelButtonAriaLabel: '取消', })
23c99e61d0a6e44afec0f5c13ea9de22.png
  • 自定义弹框的位置
Swal.fire({ position: 'top-end', type: 'success', title: '你的修改以保存', showConfirmButton: false, timer: 1500 })
20c9fce57e9b2b92f1268abd09acf9b4.png
  • 函数回调
Swal.fire({ title: '确定要删除么?', text: "删除后将无法撤销!
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值