ascsoftw / livewire-toast
Livewire 包用于显示 Toast 通知
1.0.1
2021-05-25 11:07 UTC
Requires (Dev)
- livewire/livewire: ^2.4
- orchestra/testbench: ^6.17
README
基于 TALL Stack 显示 Toast 通知的 Livewire 包。
要求
请确保您的项目中正确安装了 Livewire。
请确保您的项目中正确安装了 TailwindCSS。
请确保您的项目中正确安装了 AlpineJS。
安装
您可以使用 Composer 安装此包。
composer require ascsoftw/livewire-toast
使用方法
将 Livewire 组件 @livewire('livewire-toast')
放入您的应用程序布局的任何位置。
然后您可以这样调用 Livewire Toast:
从 Livewire 组件
$this->emitTo('livewire-toast', 'show', 'Project Added Successfully'); //Will show Success Message $this->emitTo('livewire-toast', 'showError', 'There was an Error!'); //Will show error. showError, showWarning, showInfo, showSuccess are supported $this->emitTo('livewire-toast', 'show', ['type' => 'warning', 'message' => 'This is warning!']); //Can also pass type and message as array
使用 Session Flash
session()->flash('livewire-toast', 'Project Added Successfully'); session()->flash('livewire-toast', ['type' => 'error', 'message' => 'There was an Error!']);
从 Livewire 视图
$emitTo('livewire-toast', 'show', 'Project Added Successfully'); //Will show Success Message $emitTo('livewire-toast', 'showError', 'There was an Error!'); //Will show error. showError, showWarning, showInfo, showSuccess are supported $emitTo('livewire-toast', 'show', {'type' : 'warning', 'message' : 'This is warning!'}); //Can also pass type and message as object
从 JS
Livewire.emitTo('livewire-toast', 'show', 'Project Added Successfully'); //Will show Success Message Livewire.emitTo('livewire-toast', 'showError', 'There was an Error!'); //Will show error. showError, showWarning, showInfo, showSuccess are supported Livewire.emitTo('livewire-toast', 'show', {'type' : 'warning', 'message' : 'This is warning!'}); //Can also pass type and message as object
配置
如果您想覆盖配置,必须使用以下命令发布资产
php artisan vendor:publish --tag=config
这将发布配置文件到 config/livewire-toast.php
。您可以覆盖任何配置。
您还可以使用以下命令发布视图
php artisan vendor:publish --tag=views
这将发布位于 resources/views/vendor/livewire-toast
目录中的视图,您可以对它们进行自定义。
故障排除
在使用 TailwindCSS 时,您的消息没有样式?请发布您的视图。这样 Laravel Mix 编译器将找到与包相关的视图,并相应地清理 CSS。
贡献
欢迎拉取请求。对于重大更改,请先打开一个问题以讨论您想要更改的内容。