如何在航海者中使用警报?有什么例子吗?我想在提交带有空字段的帖子时显示警报。
- 航海者版本:v0.11.14
从控制器你可以做这样的事情:
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