为什么这个 Blade 组件没有收到参数?
Why does this Blade component not receive a parameter?
我正在使用 Laravel 9 并试图了解组件。
我有这个 'anonymous' 组件(提取):
<option value="{{ $phase->id }}" @if(isset($phase_id) && $phase_id===$phase->id) selected @endif>
{{ $phase->name }}
</option>
组件是这样调用的:
<x-select-phase id="phase_id" name="phase_id" :phase_id="$event->phase_id"
我希望 var $phase_id
存在于组件内部。事实并非如此,不明白为什么。我尝试了很多事情都没有成功。接下来我可以尝试什么?
https://laravel.com/docs/9.x/blade#casing
Component constructor arguments should be specified using camelCase
, while kebab-case
should be used when referencing the argument names in your HTML attributes.
这意味着:
:phase-id="$event->phase_id"
应该生成一个变量:
$phaseId
我正在使用 Laravel 9 并试图了解组件。
我有这个 'anonymous' 组件(提取):
<option value="{{ $phase->id }}" @if(isset($phase_id) && $phase_id===$phase->id) selected @endif>
{{ $phase->name }}
</option>
组件是这样调用的:
<x-select-phase id="phase_id" name="phase_id" :phase_id="$event->phase_id"
我希望 var $phase_id
存在于组件内部。事实并非如此,不明白为什么。我尝试了很多事情都没有成功。接下来我可以尝试什么?
https://laravel.com/docs/9.x/blade#casing
Component constructor arguments should be specified using
camelCase
, whilekebab-case
should be used when referencing the argument names in your HTML attributes.
这意味着:
:phase-id="$event->phase_id"
应该生成一个变量:
$phaseId