abushamleh / yii2-toast
Yii2 toast 提醒
dev-master
2018-11-04 22:41 UTC
Requires
- yiisoft/yii2: ~2.0
This package is not auto-updated.
Last update: 2024-09-18 05:10:58 UTC
README
运行Composer命令以安装最新版本
composer require abushamleh/yii2-toast "dev-master"
用法
ToastAlert
use abushamleh\toast\ToastAlert; echo ToastAlert::widget([ 'options' => [], 'heading' => 'heading', 'text' => 'text', 'type' => 'type', ]);
ToastBlock
ToastBlock小部件从会话闪存中渲染消息。所有闪存消息都按使用setFlash分配的顺序显示。
use abushamleh\toast\ToastBlock; //You can set message as following: Yii::$app->session->setFlash('error', 'This is the message'); Yii::$app->session->setFlash('success', 'This is the message'); Yii::$app->session->setFlash('info', 'This is the message'); Yii::$app->session->setFlash('info', ['heading' => 'Message title' 'text' => 'This is the message']); //Multiple messages could be set as follows: Yii::$app->session->setFlash('error', ['Error 1', 'Error 2']); Yii::$app->session->setFlash('error', [['heading' => 'Message title' 'text' => 'This is the message'], 'Error 2']); echo ToastBlock::widget([ 'options' => [] ]);