在Laravel 7中,我开始使用视图组件(View Components)。
我正在尝试像这样从一个组件将$attributes
变量传递到另一个组件中:
x-modal组件:
<div {{ $attributes->merge(['class' => 'modal fade']) }}>
Something great...
</div>
<x-modal {{ $attributes }}>
Something great too
</x-modal>
在这种情况下,我在x-modal组件中有一个id属性,如下所示:
<x-modal-form id="aRandomId" title="Test"></x-modal-form>
但在这种情况下,id aRandomId 没有传递到x-modal组件。由于{{ $attributes }}出现错误"syntax error, unexpected 'endif' (T_ENDIF), expecting end of file"。 你知道该怎么做吗?