![](/img/trans.png)
[英]Laravel + Livewire application loses the filters when I change the page
[英]How can I change page title when I use full page components-Livewire
<head>
<title>dynamic title here - {{ config('app.name') }}</title>
</head>
如果你试试这个,请告诉我。
我更喜欢使用 JavaScript 和 Blade Components document.title = 'My Title'
用Alpine JS实现
刀片组件 (.../components/page-title.blade.php)
@props(['title'])
<div x-data x-init="document.title = @js($title.' - '.config('app.name'))"></div>
所以你可以像这样在你的刀片中的任何地方调用page-title
组件
<x-page-title :title="'Homepage'" />
可能有更简单的方法可以用 JavaScript 的方式来做,但这是我能想到的。 希望能帮助到你
PHP 的方式可能是将$title
作为道具传递给布局,例如
<x-guest-layout :page-title="$title">
... Page Content
</x-guest-layout>
guest-layout.blade.php
现在看起来像
@props(['title'])
<html>
<head>
<title>{{ $title }}</title>
</head>
<body>
{{ $slot }}
</body>
</html>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.