laravel 8x livewire 使用 livewire 时给出 Undefined 变量

laravel 8x livewire give Undefined variable when livewire use

我对这段代码感到困惑。我不知道为什么这是错误的。 这是 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]);
}