![](/img/trans.png)
[英]Laravel Livewire: how to force refresh of a computed property (and the DOM)?
[英]Laravel Livewire - How to force parent component refresh?
我想在更新子組件時刷新父組件。
我有一個組件“base.blade.php”,在該文件中,有一個購物車計數部分。 它在渲染 function 中像這樣調用孩子:
return view('livewire.admin-dashboard')->layout('layouts.base');
當增加和減少產品數量時,子組件需要更新基礎刀片文件中的購物車信息。 我該怎么做?
此致。
兒童火線
function increment() {
$this->emit('reRenderParent');
}
父組件
protected $listeners = ['reRenderParent'];
public function reRenderParent()
{
$this->mount();
$this->render();
}
父組件
protected $listeners = [
'refreshParent' => '$refresh',
];
子組件
public function save(){
... //your update code
$this->emitUp('refreshParent');
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.