bfg/livewire

Livewire 搜索器

维护者

详细信息

github.com/bfg-s/livewire

源代码

问题

安装: 61

依赖: 0

建议者: 0

安全: 0

星标: 2

关注者: 2

分支: 1

公开问题: 0

类型:bfg-app

1.4.0 2022-11-06 21:21 UTC

This package is auto-updated.

Last update: 2024-09-04 17:17:18 UTC


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

访问

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);