如何解决Laravel Livewire:开放模式
我有一张带有标记的地图。如果单击此标记,它将在其后面运行php。模态和标记是相同的组件。单击如何打开该组件?我已经尝试过x-on和dispatchBrowserEvent。
我有一种可以使用按钮的方法,但是不适用于此方法(wire:click =“”)。
组件:
<script>
var hqicon = L.icon({
iconUrl: '{{ asset('assets/map-icons/hq-icon.png') }}',iconSize: [30,30]
});
var maker = L.marker([{{ Auth::user()->company->hq->lat() }},{{ Auth::user()->company->hq->lon() }}],{icon: hqicon}).addTo(map)
.on('click',function (e) {
window.livewire.emit('launchHqModal')
});
</script>
<x-jet-dialog-modal wire:model="HqModal" id="HqModal">
<x-slot name="title">
{{ __('Hoofdkantoor') }}
</x-slot>
<x-slot name="content">
</x-slot>
<x-slot name="footer">
</x-slot>
</x-jet-dialog-modal>
组件php:
<?php
namespace App\Http\Livewire\Map;
use Livewire\Component;
class HqMarker extends Component
{
public $launchHqModal = false;
protected $listeners = ['launchHqModal'];
public function launchHqModal()
{
$this->dispatchBrowserEvent('launch-hq-modal');
$this->emit('launch-hq-modal');
$this->launchHqModal = true;
}
/**
* Get the view / contents that represent the component.
*
* @return \Illuminate\View\View|string
*/
public function render()
{
return view('map.hq-marker');
}
}
预先感谢
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。