Readouble

Livewire v3 wire:current

wire:current

wire:current ディレクティブを使用すると、ページ上の現在アクティブなリンクを簡単に検出してスタイルを設定できます。The wire:current directive allows you to easily detect and style currently active links on a page.

wire:current をナビゲーションバーのリンクに追加して、現在アクティブなリンクのフォントウェイトを強くする簡単な例を次に示します。Here's a simple example of adding wire:current to links in a navbar so that the currently active link has a stronger font weight:

<nav>
    <a href="/dashboard" ... wire:current="font-bold text-zinc-800">Dashboard</a>
    <a href="/posts" ... wire:current="font-bold text-zinc-800">Posts</a>
    <a href="/users" ... wire:current="font-bold text-zinc-800">Users</a>
</nav>

これで、ユーザーが /posts にアクセスすると、"Posts" リンクは他のリンクよりも強いフォントで表示されます。Now when a user visits /posts, the "Posts" link will have a stronger font treatment than the other links.

wire:current は、wire:navigate リンクとページの変更でそのまま動作することに注意してください。You should note that wire:current works out of the box with wire:navigate links and page changes.

完全一致Exact matching

デフォルトでは、wire:current は部分一致戦略を使用します。つまり、リンクと現在のページが URL のパスの先頭部分を共有している場合に適用されます。By default, wire:current uses a partial matching strategy, meaning it will be applied if the link and current page share the beginning portion of the Url's path.

たとえば、リンクが /posts で、現在のページが /posts/1 の場合、wire:current ディレクティブが適用されます。For example, if the link is /posts, and the current page is /posts/1, the wire:current directive will be applied.

完全一致を使用する場合は、.exact 修飾子をディレクティブに追加できます。If you wish to use exact matching, you can add the .exact modifier to the directive.

ユーザーが /posts にアクセスしたときに "Dashboard" リンクが強調表示されないようにするために、完全一致を使用する例を次に示します。Here's an example where you might want to use exact matching to prevent the "Dashboard" link from being highlighted when the user visits /posts:

<nav>
    <a href="/" wire:current.exact="font-bold">Dashboard</a>
</nav>

厳密な一致Strict matching

デフォルトでは、wire:current は比較から末尾のスラッシュ (/) を削除します。By default, wire:current will remove trailing slashes (/) from its comparison.

この動作を無効にして、厳密なパス文字列の比較を強制する場合は、.strict 修飾子を追加できます。If you'd like to disable this behavior and force a stract path string comparison, you can append the .strict modifier:

<nav>
    <a href="/posts/" wire:current.strict="font-bold">Dashboard</a>
</nav>

トラブルシューティングTroubleshooting

wire:current が現在のリンクを正しく検出しない場合は、以下を確認してください。If wire:current is not detecting the current link correctly, ensure the following:

  • ページに少なくとも 1 つの Livewire コンポーネントがあるか、レイアウトに @livewireScripts をハードコードしていることYou have at least one Livewire component on the page, or have hardcoded @livewireScripts in your layout
  • リンクに href 属性があることYou have a href attribute on the link.

章選択

パッケージ

設定

バージョン変更
linkv3 linkv2
明暗テーマ
light_mode
dark_mode
brightness_auto システム設定に合わせる
テーマ選択
photo_size_select_actual デフォルト
photo_size_select_actual モノクローム(白黒)
photo_size_select_actual Solarized風
photo_size_select_actual GitHub風(青ベース)
photo_size_select_actual Viva(黄緑ベース)
photo_size_select_actual Happy(紫ベース)
photo_size_select_actual Mint(緑ベース)
コードハイライトテーマ選択

明暗テーマごとに、コードハイライトのテーマを指定できます。

テーマ配色確認
スクリーン表示幅
640px
80%
90%
100%

768px以上の幅があるときのドキュメント部分表示幅です。

インデント
無し
1rem
2rem
3rem
原文確認
原文を全行表示
原文を一行ずつ表示
使用しない

※ 段落末のEボタンへカーソルオンで原文をPopupします。

Diff表示形式
色分けのみで区別
行頭の±で区別
削除線と追記で区別

※ [tl!…]形式の挿入削除行の表示形式です。

テストコード表示
両コード表示
Pestのみ表示
PHPUnitのみ表示
OS表示
全OS表示
macOSのみ表示
windowsのみ表示
linuxのみ表示
JSフレームワーク
両フレームワーク
Reactのみ表示
Vueのみ表示
JSのみ表示

(JSが存在しない場合は、他を全表示)

和文変換

対象文字列と置換文字列を半角スペースで区切ってください。(最大5組各10文字まで)

本文フォント

総称名以外はCSSと同様に、"〜"でエスケープしてください。

コードフォント

総称名以外はCSSと同様に、"〜"でエスケープしてください。

保存内容リセット

localStrageに保存してある設定項目をすべて削除し、デフォルト状態へ戻します。

ヘッダー項目移動

キーボード操作