Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/440.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 通过调度触发云杉烤面包机_Javascript_Laravel Livewire_Alpine.js - Fatal编程技术网

Javascript 通过调度触发云杉烤面包机

Javascript 通过调度触发云杉烤面包机,javascript,laravel-livewire,alpine.js,Javascript,Laravel Livewire,Alpine.js,所以我在我的高项目上尝试了这个(代码如下) 我在toaster通知脚本下面添加的是 window.addEventListener('toast', event => { $store.toasts.createToast(event.detail.message, event.detail.type); }) 这不管用,有什么建议吗?想出来了。我已将alpine方法添加到根元素: x-on:alert.window="$store.toasts.cre

所以我在我的高项目上尝试了这个(代码如下)

我在toaster通知脚本下面添加的是

window.addEventListener('toast', event => {
        $store.toasts.createToast(event.detail.message, event.detail.type);
    })

这不管用,有什么建议吗?

想出来了。我已将alpine方法添加到根元素:

x-on:alert.window="$store.toasts.createToast($event.detail.message, $event.detail.type)"
现在要触发,我必须在livewire组件上使用dispatch,如下所示:

$this->dispatchBrowserEvent('alert', ['type' => 'success', 'message' => 'Files Uploaded']);
x-on:alert.window="$store.toasts.createToast($event.detail.message, $event.detail.type)"
$this->dispatchBrowserEvent('alert', ['type' => 'success', 'message' => 'Files Uploaded']);