bfg / livewire
Livewire 搜索器
1.4.0
2022-11-06 21:21 UTC
Requires
- php: ^7.2.5|^8.0
- livewire/livewire: ^2.5
README
为 Livewire
包提供扩展。增加组件搜索和扩展功能,支持 Alpine、Turbolink、SweetAlert2 和 Toastr。
安装
composer required bfg/livewire
用法
视图
@extends('livewire::document') @section('head') <title>Main</title> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"/> @endsection @section('body') @yield('content') @endsection @section('footer') @endsection
Turbolinks
- @turbolinks(false) - 禁用特定链接的 Turbolinks
- @turbolinksEval - 与 Script 元素一起使用
- @turbolinksPermanent - 在页面加载之间持久化元素
- @turbolinksTrackReload - 当资源更改时重新加载
- @turbolinksActionReplace - 应用访问
访问
window.Turbolinks.visit("/edit", { action: "replace" })
SweetAlert2
访问
window.Swal.fire('Any fool can use a computer')
Toastr
访问
window.Toastr.info('Are you the 6 fingered man?')
Livewire 事件
简单 Swal 访问
class MyComponent extends \Livewire\Component { ... public function submit() { $this->emit('swal', [ 'icon' => 'error', 'title' => 'Oops...', 'text' => 'Something went wrong!', 'footer' => '<a href="">Why do I have this issue?</a>' ]); } ... }
Swal 确认访问
... $this->emit('swal:confirm', [ 'title' => 'Do you want to save the changes?', 'text' => 'Save changes', 'confirmEvent' => 'livewireEvent', // You livewire event 'confirmParams' => ['user_id' => 1], // You livewire event parameters ]); ...
Swal 消息访问
... $this->emit('swal:success', [ 'title' => 'Changes saved!', 'text' => 'All you changes is saved' ]); // Or $this->emit('swal:success', [ // Can be: success, error, warning, info 'Changes saved!', 'All you changes is saved' ]); ...
Toastr 消息访问
... $this->emit('toastr:success', 'Changes saved!'); $this->emit('toastr:success', [ // Can be: success, error, warning, info 'Changes saved!', 'All you changes is saved', ['timeOut' => 5000] ]); ...
Turbolinks 访问
... $this->emit('visit', '/edit'); // Or $this->emit('visit', [ '/edit', ['action' => 'replace'] ]); ...
扩展
对于注入文件夹,您可以这样做
Bfg\Livewire\LivewireComponentsFinder::directory('Admin\\Pages', __DIR__.'/../Pages');
LivewireComponentsFinder::directory(string $namespace, string $path);