【发布时间】:2017-12-13 08:20:39
【问题描述】:
如何在 voyager 中使用警报?有什么例子吗?我想在提交带有空字段的帖子时显示警报。
- 航海者版本:v0.11.14
【问题讨论】:
如何在 voyager 中使用警报?有什么例子吗?我想在提交带有空字段的帖子时显示警报。
【问题讨论】:
从控制器你可以做这样的事情:
return redirect('path')->with(['message' => "Your Success Message", 'alert-type' => 'success']);
或者:
return redirect('path')->with(['message' => "Your Error Message", 'alert-type' => 'error']);
【讨论】:
Voyager 使用 toastr 库,要简单地使用它,您可以使用以下方式将其作为事件触发:
Toastr::warning($message, $title = null, $options = []) - add a warning toast
Toastr::error($message, $title = null, $options = []) - add an error toast
Toastr::info($message, $title = null, $options = []) - add an info toast
Toastr::success($message, $title = null, $options = []) - add a success toast
Toastr::add($type: warning|error|info|success, $message, $title = null, $options = []) - add a toast
Toastr::clear() - clear all current toasts
【讨论】: