javascript - 如何在 laravel 5.6 中使用 toastify-js?
问题描述
Toastify JS:https ://apvarun.github.io/toastify-js/
我想将 toastify js 与我的 laravel 项目集成以进行 toast 通知。
解决方案
在 laravel 的情况下,您已将其添加到页眉和页脚 app.css 和 app.js 中。和我们做的 HTML 一样。
使用传统方法将 ToastifyJs 添加到 HTML 页面
要开始使用 Toastify,请将以下 CSS 添加到您的页面。
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/toastify-js/src/toastify.min.css">
以及页面底部的脚本
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/toastify-js"></script>
文件通过 jsdeliver 提供的 CDN 服务交付
文档
Toastify({
text: "This is a toast",
duration: 3000,
destination: "https://github.com/apvarun/toastify-js",
newWindow: true,
close: true,
gravity: "top", // `top` or `bottom`
positionLeft: true, // `true` or `false`
backgroundColor: "linear-gradient(to right, #00b09b, #96c93d)",
}).showToast();