我已将softon/sweetalert中的sweetalert2软件包用于laravel项目。一切正常,但似乎令人困惑,我不知道如何实现类似swal.showLoading()的加载图标;使用这种方法。下面是我在UserController上的代码:
public function store(UserRequest $request)
{
$user_email = $request['email'];
$user_active = User::where('email', 'LIKE', $user_email)->whereNull('deleted_at')->count();
if ($user_active < 1) {
$user = User::create([
'name' => $request['name'],
'email' => $request['email'],
'password' => $request['password'],
'is_active' => 1,
]);
swal()->autoclose(2000)->message('Success', 'Record has been successfully added.', 'success', ['showConfirmButton' => false, 'onOpen' => '() => { swal.showLoading(); }']);
return redirect()->route('user.index');
} else {
swal()->error('Error', 'Adding record failed, ' . $request['email'] . ' already exist.');
return redirect()->route('user.index');
}
}
我试图在swal helper函数上实现类似这样的参数,但是不起作用。
'onOpen' => '() => { swal.showLoading(); }'
有什么想法可以做到吗?