【发布时间】:2021-03-07 06:06:25
【问题描述】:
看看下面的例子:
showPost.blade.php:
<div>
<livewire:content-box :content="$post"/>
<button wire:click="nextPost" >Next Post >></button>
</div>
和 内容框.blade.php:
<div>
<h1>{{ $content->title }}</h1>
<p>{{ $content->content }}</p>
</div>
到目前为止,完全清楚接下来会发生什么……:首先,通过showPost接收要查看的内容的信息,并传递给contentBox,一切正常..
现在我想通过我放置的按钮并调用nextPost方法通过帐户获取下一个内容的信息:
class ShowPost extends Component
{
public Post $post;
public function render()
{
return view('livewire.show-post');
}
public function nextPost()
{
$id = $this->post->id;
$nextPost = Post::where('id', '>', $id)->first();
$this->post = $nextPost;
}
...
但是什么都没有发生,contentBox 组件也没有反应....有人遇到过这个问题吗???!
【问题讨论】:
标签: laravel components laravel-livewire