Yii2提示信息设置方法
显示信息提示用户时,可以用setFlash,hasFlash,getFlash
function actionOk() { Yii::app()->user->setFlash('success', 'Everything went fine!'); $this->redirect('index'); } function actionBad() { Yii::app()->user->setFlash('error', 'Everything went wrong!'); $this->redirect('index'); }
提示的隐藏
views中添加
<?php $js = <<<JS $(function(){ $(".alert").animate({opacity: 1.0}, 1000).fadeOut("slow"); JS; $this->registerJs($js); ?>