yii2mod/yii2-sweet-alert

定时关闭问题

Opened this issue · 0 comments

实现效果:定时关闭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()});";
定时效果搞定