marqu3s / yii2-sweet-alert
基于 SweetAlert 扩展的 Alert 小部件 http://tristanedwards.me/sweetalert
v1.0.0
2017-09-18 17:26 UTC
Requires
- bower-asset/sweetalert: *
- yiisoft/yii2: *
This package is auto-updated.
Last update: 2024-09-24 20:24:53 UTC
README
- 基于 SweetAlert 扩展的 Alert 小部件 http://tristanedwards.me/sweetalert
- 从 yii2mod/yii2-sweet-alert 分支 fork 并适应了我的需求。
安装
安装此扩展的首选方式是通过 composer。
运行以下命令之一
php composer.phar require --prefer-dist marqu3s/yii2-sweet-alert "*"
或
"marqu3s/yii2-sweet-alert": "*"
将以下内容添加到您的 composer.json 文件的 require 部分。
使用方法
安装扩展后,只需将小部件添加到您的页面,如下所示
- 默认用法,通过 Yii::$app->session->setFlash() 渲染存储在会话 flash 中的所有闪存消息。
echo Alert::widget();
- 自定义用法示例
echo Alert::widget([ 'useSessionFlash' => false, 'options' => [ 'title' => 'Success message', 'type' => 'Success', 'text' => "You will not be able to recover this imaginary file!", 'confirmButtonText' => "Yes, delete it!", 'cancelButtonText' => "No, cancel plx!" ] ]);
Alert 选项
您可以在 选项页面 找到它们