以下代码不显示数据。但是,如果我 dd 数据它可以工作
Livewire 公司.php:
public $company;
public function mount(Company $company) {
$this->company = $company;
}
public function render()
{
return view('livewire.company');
}
livewire.公司:
<div>
{{$company->name}}</div>
虽然如果我 dd $company->name 它可以工作
网页.php:
Route::livewire('/companies/{company}', 'company')->name('show-company');
布局/app.blade.php:
@livewireStyles @livewire('company') <script src="{{asset('js/app.js')}}"></script> @livewireScripts
另外,如果我不使用 Route Model Binding 而是像这样查找它
$this->company = Company::find($company);
它抛出不可解析的依赖解析 [Parameter #0 [ $company ]]