SpringBoot+SweetAlert2(附源码)

本文介绍了如何在SpringBoot项目中集成并使用SweetAlert2,包括在pom.xml添加依赖,引入页面文件,展示各种类型的对话框如基本信息、带标题图标文本、自定义HTML、插入图片、自定义背景、自动关闭、信息提示、input输入框、按钮及Ajax请求等,并提供了源码链接。
摘要由CSDN通过智能技术生成

SweetAlert2是一款功能强大的纯Js模态消息对话框插件

先附上源码https://gitee.com/zlh0816/SpringBootSweetAlert2


一、前期准备

① 在pom.xml中添加依赖
// sweetalert2依赖
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>sweetalert2</artifactId>
    <version>2.1.3.RELEASE</version>
</dependency>

// 添加jquery包
<dependency>
    <groupId>org.webjars</groupId>
    <artifactId>jquery</artifactId>
    <version>3.3.1-1</version>
</dependency>
② 在页面中引入文件
//sweetalert2 css文件
<link rel="stylesheet" href="webjars/sweetalert2/7.28.10/dist/sweetalert2.min.css">

//sweetalert2 js文件
<script src="webjars/sweetalert2/7.28.10/dist/sweetalert2.min.js"></script>

//jquery文件
<script src="webjars/jquery/3.3.1-1/jquery.min.js"></script>

二、使用

1. 基本信息
Swal.fire({
   
    title: "标题",
    text: "文本"
})

在这里插入图片描述

2. 带有标题、图标、文本的信息
Swal.fire({
   
    title: "标题",
    text: "文本",
    type: "success"
})

在这里插入图片描述

3. 插入自定义HTML描述
Swal.fire({
   
    title: "标题",
    html: "<a href='javascript:void(alert(0))'>超链接</a>",
    type: "info"
  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值