Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to solve the problem of vue integrating sweetalert2 prompt components

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces how to solve the problem of vue integrated sweetalert2 prompt components, the article is very detailed, has a certain reference value, interested friends must read it!

I. Project integration

Official website link: https://sweetalert2.github.io

Case

1. Introduction method CDN introduction method:

Global introduction in index.html

Location:

Npm installation method:

Npm install sweetalert22. The confirmation box encapsulates Confirm = {show: function (message, callback) {Swal.fire ({title: 'confirm?', text: message, icon: 'warning', showCancelButton: true, confirmButtonColor:' # 3085d6 confirmation, cancelButtonColor:'# d33 confirmation, confirmButtonText: 'yes Confirmed!'}). Then ((result) = > {if (result.isConfirmed) {if (callback) {callback ()})} 3. Prompt box encapsulates Toast = {success: function (message) {Swal.fire ({position: 'top-end', icon:' success', title: message, showConfirmButton: false, timer: 3000})}, error: function (message) {Swal.fire ({position: 'top-end') Icon: 'error', title: message, showConfirmButton: false, timer: 3000})}, warning: function (message) {Swal.fire ({position:' top-end', icon: 'warning', title: message, showConfirmButton: false Timer: 3000})}} 4. Confirm box using / * Click [delete] * / del (id) {let _ this = this Confirm.show ("cannot be recovered after deletion, confirm deletion!" Function () {Loading.show () _ this.$api.delete ('http://127.0.0.1:9000/business/admin/chapter/delete/' + id). Then ((res) = > {Loading.hide () console.log ("Delete big chapter list result:" Res) let resp = res.data if (resp.success) {_ this.list (1) Swal.fire ('deleted successfully!', 'deleted successfully!' , 'success')}})}) 5. The message prompt box uses / * Click [Save] * / save () {let _ this = this Loading.show () _ this.$api.post ('http://127.0.0.1:9000/business/admin/chapter/save', _ this.chapter). Then ((res) = > {Loading.hide () console.log ("Save big chapter list results:" Res) let resp = res.data if (resp.success) {$("# form-modal"). Modal ("hide") _ this.list (1) Toast.success ("saved successfully!") } else {Toast.warning (resp.message)}})} 6. Project effect

These are all the contents of this article entitled "how to solve the problem of integrating sweetalert2 prompt components in vue". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report