我有帶有添加按鈕的類別組件,如下所示。
<button wire:click.prevent="addNew" class="btn btn-primary mb-2">Add</button>
.....
.....
<x-mymodal-component :iscreate="$iscreate"/>
使用“addNew”方法,我將事件分派給 javascript 偵聽器。
public function addNew(){
$this->dispatchBrowserEvent('show-category-modal');
}
在偵聽器事件中,我嘗試顯示作為組件制作的模態。
window.addEventListener('show-category-modal', event => {
$('#category-form').modal('show');
});
下面是需要傳入資料的模態組件。
<x-mymodal-component :iscreate="$iscreate"/>
對此的任何建議或指導將不勝感激,謝謝。
uj5u.com熱心網友回復:
@livewire('mymodal-component', ['iscreate'=>$iscreate])
//Receive:
public function mount($iscreate)
{
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/380522.html
