我对这段代码感到困惑。我不知道为什么这是错误的。这是 livewire 功能:
public $members;
public function render()
{
$this->members = "members";
return view('livewire.members');
}
和观点:
<div>
<h1>{{$members}}</h1>
</div>
我对这段代码感到困惑。我不知道为什么这是错误的。这是 livewire 功能:
public $members;
public function render()
{
$this->members = "members";
return view('livewire.members');
}
和观点:
<div>
<h1>{{$members}}</h1>
</div>
尝试在渲染之前定义变量。
public $members = 'members';
// or
public function mount()
{
$this->members = "members";
}
public function render()
{
$this->members = 'members';
return view('livewire.members');
}
对于 Laravel。将您的变量传递给视图。
public function render()
{
$members = "members";
// $this->members = "members";
return view('livewire.members', ['members' => $members]);
// return view('livewire.members', ['members' => $this->members]);
}