bpocallaghan / alert
一个辅助包,用于将 Bootstrap 警报快速显示到浏览器。
1.2.3
2024-06-18 10:37 UTC
Requires
- php: >=7.0.0
This package is auto-updated.
Last update: 2024-09-18 11:12:00 UTC
README
一个辅助包,通过外观或辅助函数将 Bootstrap 警报快速显示到浏览器。
<div class="alert alert-info fade in"> <i class="fa-fw fa fa-smile-o"></i> <strong>Title</strong> Description </div>
###想看看当前包的实际应用,请查看我的启动项目。###Laravel 启动项目
安装
首先,通过 Composer 引入此包。
"require": { "bpocallaghan/alert": "1.*" }
或者
composer require bpocallaghan/alert
使用方法
在任何视图文件中。
@include('alert::alert')
在任何控制器中。
public function index() { // helper function - default to the 'info' alert('Title', 'Lorem Ipsum'); // return object first alert()->info('Title', 'Lorem Ipsum'); // via the facade Alert::info('Title', 'Lorem Ipsum'); return view('home'); }
不同的 '级别' 有:
alert()->info('标题', 'Lorem Ipsum');
alert()->success('标题', 'Lorem Ipsum');
alert()->warning('标题', 'Lorem Ipsum');
alert()->danger('标题', 'Lorem Ipsum');
不同的参数
alert()->info('标题', 'Lorem Ipsum', false);
// 不显示图标alert()->info('标题', 'Lorem Ipsum', 'smile-o');
// 指定图标类alert()->info('标题', 'Lorem Ipsum', 'smile-o', true);
// 将警报限制在请求生命周期内alert()->message('标题', 'Lorem Ipsum', 'smile-o', true, 'info');
// 指定级别的类型alert()->message('标题', 'Lorem Ipsum', 'smile-o', true, 'info', false);
// 不显示 '关闭' 按钮
如果需要修改视图部分,你可以运行
php artisan vendor:publish --provider="Bpocallaghan\Alert\AlertServiceProvider"
视图部分可以在以下位置找到 resources\views\vendor\alert\alert.blade
。