roksta / toast
laravel 中的 Toastr 通知
v1.3.0
2019-10-15 11:57 UTC
Requires
- php: >=5.4.0
README
为 laravel 提供简单的 Toastr 通知
安装
使用 composer 安装此包
composer require roksta/toast
Laravel 自动发现将找到所需的服务提供者和别名。
Toastr
默认情况下,Toastr 通过 CDN 启用。
运行
php artisan vendor:publish --provider="Roksta\Toastr\ToastrServiceProvider"
以发布你的资源/资产/供应商/roksta/toastr.blade.php 中的包视图
在你的主视图的 jQuery 文件导入下添加 @include('vendor.roksta.toastr')
,例如:
<!DOCTYPE html> <html> <head> <title></title> <link rel="stylesheet" type="text/css" href="/css/app.css"> </head> <body> <div id="app"></div> <script type="text/javascript" src="js/app.js"></script> @include('vendor.roksta.toastr') </body> </html>
使用
使用辅助函数 toast()
来创建默认通知。
toast()->success('message', 'title'); toast()->info('message', 'title'); toast()->warning('message', 'title'); toast()->error('message', 'title');
你可以通过向 toast 添加选项方法来指定由 Toastr 规定的所有其他选项。
toast()->success('message', 'title')->options([ 'timeOut' => 5000, 'closeButton' => 1, 'closeHtml' => '<button><i class="icon-off"></i></button>' ]);
注意,对于布尔值,如 closeButton => true
,应表示为 0 表示 false 或 1 表示 true
许可证
此包根据 MIT 许可证提供。