Используя Laravel Livewire, у меня есть родительский элемент и (повторяющийся) дочерний элемент. Дочерний блейд вызывает вызов childMethod() через провод:click="childMethod()".
Проблема в том, что родительский->childMethod() вызывается, когда я хотел, чтобы был вызван child->childMethod().
Родительский компонент
class StatementsTable extends Component // parent
{
public function render()
{
return view('livewire.statements-table', [
'statements' => Statement::limit(10)->get()
]);
}
}
Родительские операторы-table.blade
@foreach($statements as $statement)
@livewire('statement-line', ['statement' => $statement], key($statement->id))
@endforeach
Дочерний компонент:
class StatementLine extends Component
{
public $statement;
public $calls = 0;
public function childMethod()
{
$this->calls += 1;
}
public function mount($statement): void
{
$this->statement = $statement;
}
public function render()
{
return view('livewire.statement-line');
}
}
Дочерний оператор-line.blade
{{-- dd(get_defined_vars()) --}}
{{$statement->name}}
{{$statement->date}}
{{$calls}}
Plus
Почему я получаю
Livewire\Exceptions\MethodNotFoundException
Unable to call component method. Public method [childMethod] not found on component: [statements-table]
Подробнее здесь: https://stackoverflow.com/questions/643 ... name-not-f