所以,我目前在我的一个项目中使用了Laravel Livewire.但是,当我try 通过magic mathod $refresh
将事件从一个组件发送到另一个组件时,它的刷新(在xhr请求中获得dom)会覆盖整个组件,但前端不会实时更新.
ProductReviewForm.php
个组成部分:
public function save()
{
//some functionalities ....
$this->emit('reviewSectionRefresh');
}
ProductReviewSection.php
个组成部分:
protected $listeners = [
'reviewSectionRefresh' => '$refresh',
];
public function render()
{
$this->review_lists = ProductReview::orderBy('id', 'DESC')->get();
return view('livewire.desktop.product-review-section');
}
所以我想发出reviewSectionRefresh
个事件,每当我从第一个组件调用save()
函数时,它都会被另一个组件的$listeners
监听.这很好用.同样在xhr中,我得到了刷新的dom,但前端中的组件没有更新.希望任何与Livewire合作的人都能帮上忙.