编程

支持Laravel TALL 栈的 Toast 通知扩展包

911 2022-01-01 01:16:32

TALL Toasts 是Laravel TALL栈(Tailwind, Alpine.js, Laravel, Livewire)下的toast 通知库。该包可以从前台和后台渲染自定义 toast通知消息。同时,也能发布 CSS/JS 文件。

以下是触发toast消息的前端API:

// Frontend
Toast.info(
  'Notification from the frontend...',
  'The Title'
);
 
Toast.success('A toast without a title also works');
 
Toast.warning('Watch out!');
 
Toast.danger('I warned you!', 'Yikes');

后端示例:

// backend
toast()
    ->info('Notification from the backend...', 'The Title')
    ->push();
 
toast()
    ->success('A toast without a title also works')
    ->push();
 
toast()
    ->warning('Watch out!')
    ->push();
 
toast()
    ->danger('I warned you!', 'Yikes')
    ->push();

另外,你可以修改blade文件控制修改消息框的展示样式。