企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
# sweetalert ### alert弹出库官方<https://www.sweetalert.cn> ``` <pre class="calibre16">``` npm install sweetalert <span class="token">--</span>save import swal from <span class="token4">'sweetalert'</span><span class="token2">;</span> <span class="token6">//导入应用</span> <span class="token"><</span>script src<span class="token">=</span><span class="token4">"https://unpkg.com/sweetalert/dist/sweetalert.min.js"</span><span class="token">></span><span class="token"><</span><span class="token">/</span>script<span class="token">></span> <span class="token6">//CDN</span> <span class="token1">swal</span><span class="token2">(</span><span class="token4">"Hello world!"</span><span class="token2">,</span> <span class="token2">{</span> dangerMode<span class="token2">:</span> <span class="token3">true</span><span class="token2">,</span> buttons<span class="token2">:</span> <span class="token2">[</span><span class="token4">"取消"</span><span class="token2">,</span><span class="token4">"确定"</span><span class="token2">]</span><span class="token2">,</span> <span class="token2">}</span><span class="token2">)</span><span class="token2">.</span><span class="token1">then</span><span class="token2">(</span><span class="token2">(</span>v<span class="token2">)</span><span class="token">=</span><span class="token">></span><span class="token2">{</span> console<span class="token2">.</span><span class="token1">log</span><span class="token2">(</span>v<span class="token2">)</span> <span class="token2">}</span><span class="token2">)</span><span class="token2">;</span> <span class="token1">swal</span><span class="token2">(</span><span class="token4">"自动关闭!"</span><span class="token2">,</span> <span class="token2">{</span> buttons<span class="token2">:</span> <span class="token3">false</span><span class="token2">,</span> timer<span class="token2">:</span> <span class="token3">3000</span><span class="token2">,</span> <span class="token2">}</span><span class="token2">)</span><span class="token2">;</span> <span class="token1">swal</span><span class="token2">(</span><span class="token4">"提示"</span><span class="token2">,</span> <span class="token4">"操作成功"</span><span class="token2">,</span> <span class="token4">"success"</span><span class="token2">,</span> <span class="token2">{</span> button<span class="token2">:</span> <span class="token4">"确定"</span><span class="token2">,</span> <span class="token2">}</span><span class="token2">)</span><span class="token2">;</span> swal<span class="token2">.</span><span class="token1">stopLoading</span><span class="token2">(</span><span class="token2">)</span><span class="token2">;</span> swal<span class="token2">.</span><span class="token1">close</span><span class="token2">(</span><span class="token2">)</span><span class="token2">;</span> ``` ```