yii2mod / yii2-sweet-alert

SweetAlert widget for Yii2 framework
MIT License
43 stars 18 forks source link

定时关闭问题 #11

Open luopeihai opened 6 years ago

luopeihai commented 6 years ago

实现效果:定时关闭alert, Alert 代码: ........ echo \yii2mod\alert\Alert::widget([ 'useSessionFlash' => false, 'options' => [ 'timer' => null, 'type' => $type, 'title' => $message, 'timer'=> 1500, // 'showConfirmButton'=> false ] ]); ....... 发现并没有自动关闭,查看 源码 yii2mod/yii2-sweet-alert/Alert.php文件

...... protected function registerAssets() { if ($this->hasTitle()) { $view = $this->getView(); AlertAsset::register($view); //var_dump($this->getOptions());exit; $js = "sweetAlert({$this->getOptions()}, {$this->callback});"; $view->registerJs($js, $view::POS_END); } } ....... 把 $js = "sweetAlert({$this->getOptions()}, {$this->callback});"; 改为
$js = "sweetAlert({$this->getOptions()});"; 定时效果搞定