php-Livewireコンポーネントは独自のコードを表示しますが、レンダリングしません
LivewireでLaravelJetstreamを使用しています。ドキュメントに従って独自のLivewireコンポーネントを作成しようとしています:
php artisan livewire:make my_component
デフォルトでは、 resources/views/livewire/my-component.blade.php
にあります。この文字列をresources/views/profile/show.blade.php
ファイルに追加しました: @livewire('my-component')
。このコンポーネントをユーザープロファイルページに表示したい。
しかし、コンポーネントの代わりに、ページにそのコードしか表示されません。
この写真では、 two-factor-authentication-form.blade.php
の代わりにコンポーネントを追加しました。 resources/views/liwevire/my-component.blade.php
のコードは次のとおりです:
<x-jet-action-section>
<x-slot name="title">
{{ __('Two Factor Authentication') }}
</x-slot>
<x-slot name="description">
{{ __('Add additional security to your account using two factor authentication.') }}
</x-slot>
<x-slot name="content">
Some content
</x-slot>
</x-jet-action-section>
これがresources/views/profile/show.blade.php
のコードです:
@if(Laravel \ Fortify \ Features :: canManageTwoFactorAuthentication())
<->
{-コード-4}
@endif
どうすれば修正できますか?
P。 S. resources/views/profile/show.blade.php
からコメント行を削除しましたが、まだ何もありません。コードは次のとおりです:
@if(Laravel \ Fortify \ Features :: canManageTwoFactorAuthentication())
{-コード-4}
@endif
P.P.S。 app/Http/Livewire/MyComponent
のコードは次のとおりです:
<?php
namespace App\Http\Livewire;
use Livewire\Component;
class MyComponent extends Component
{
public function render()
{
return view('livewire.my-component');
}
}
わからない
0 レビュー
答え :
解決策:
HTMLコメントを使用してブレードレンダリングされたコンポーネントをコメントアウトする場合は、コメントの間にブレードコンポーネントがレンダリングされるため、注意が必要です。
<!-- @livewire('profile.two-factor-authentication-form') -->
使用{{--}}
{{-- @livewire('profile.two-factor-authentication-form') --}}
答えへのリンク
わからない
同様の質問
私たちのウェブサイトで同様の質問で答えを見つけてください。