3

如何在航海者中使用警报?有什么例子吗?我想在提交带有空字段的帖子时显示警报。

  • 航海者版本:v0.11.14
4

2 回答 2

8

从控制器你可以做这样的事情:

return redirect('path')->with(['message' => "Your Success Message", 'alert-type' => 'success']);

或者:

return redirect('path')->with(['message' => "Your Error Message", 'alert-type' => 'error']);
于 2018-03-25T13:01:51.363 回答
5

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
于 2017-08-08T13:23:50.900 回答