ofilin / yii2-sweetalert
甜心警报资源
0.1
2019-06-27 13:36 UTC
Requires
- yiisoft/yii2: ~2.0.0
This package is auto-updated.
Last update: 2024-09-28 22:17:20 UTC
README
yii2-sweetalert
此资源覆盖了标准的JavaScript yii.confirm
方法。插件 SweetAlert2
安装
安装此扩展的首选方式是通过 composer。
运行以下命令之一:
composer require --prefer-dist ofilin/yii2-sweetalert "*"
或添加
"ofilin/yii2-sweetalert": "*"
到您的 composer.json
文件的 require 部分,并运行 composer update
配置
在您的资源文件中添加此 SweetAlertAsset
public $depends = [
'yii\web\YiiAsset',
'yii\bootstrap\BootstrapAsset',
\ofilin\sweetalert\SweetAlertAsset::class,
];
或注册到视图文件
\ofilin\sweetalert\SweetAlertAsset::register($this);
显示警报
基本警报
<?= \ofilin\sweetalert\SweetAlertWidget::widget(['pluginOptions' => [
'type' => 'error',
'title'=>'Oops...',
'text' => 'Something went wrong!',
]]) ?>
闪存警报
// in controller
Yii::$app->session->setFlash('success', "Статья сохранена");
<!-- in view/layout -->
<?= \ofilin\sweetalert\SweetAlertWidget::widget(['isFlash' => true]) ?>