英文:
Why is my laravel-livewire ->layout not working?
问题
我正在尝试使用Livewire模型为我的页面应用样式,但它不起作用,我找不到原因。以下是我的模型代码:
<?php
namespace App\Http\Livewire;
use Livewire\Component;
class Home extends Component
{
public function render()
{
return view('livewire.home')
->layout('layouts.tesswimlayout');
}
}
布局文件:
<!doctype html>
<html lang="nl">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://unpkg.com/alpinejs" defer></script>
<meta name="description" content="Welkom bij TS">
<title>TS: {{ $title ?? '' }}</title>
@vite(['resources/css/app.css', 'resources/js/app.js'])
@livewireStyles
</head>
<body class="font-sans antialiased">
<div class="flex flex-col space-y-4 min-h-screen text-gray-800 bg-gray-100">
<header class="shadow bg-white/70 sticky inset-0 backdrop-blur-sm z-10">
{{-- Navigation --}}
<nav class="container mx-auto p-4 flex justify-between items-center">
<a href="{{ route('home') }}" class="underline">Home</a>
</nav>
</header>
<main class="container mx-auto p-4 flex-1 px-4">
{{-- Main content --}}
{{ $slot }}
</main>
<x-layout.footer.footer/>
</div>
@stack('script')
</body>
</html>
我确定这是一个简单的错误,但我目前完全迷失,所以任何帮助都会感激。
英文:
i'm trying to apply a style to my page using a Livewire model but it does not work and i can't find why.
Here is the code of my model:
<?php
namespace App\Http\Livewire;
use Livewire\Component;
class Home extends Component
{
public function render()
{
return view('livewire.home')
->layout('layouts.tesswimlayout');
}
}
Layout File
<!doctype html>
<html lang="nl">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-
scale=1.0">
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://unpkg.com/alpinejs" defer></script>
<meta name="description" content="Welkom bij TS">
<title>TS: {{ $title ?? '' }}</title>
@vite(['resources/css/app.css', 'resources/js/app.js'])
@livewireStyles
</head>
<body class="font-sans antialiased">
<div class="flex flex-col space-y-4 min-h-screen text-gray-800
bg-gray-100">
<header class="shadow bg-white/70 sticky inset-0 backdrop-blur-sm
z-10">
{{-- Navigation --}}
<nav class="container mx-auto p-4 flex justify-between items-
center">
<a href="{{ route('home') }}" class="underline">Home</a>
</nav>
</header>
<main class="container mx-auto p-4 flex-1 px-4">
{{-- Main content --}}
{{ $slot }}
</main>
<x-layout.footer.footer/>
</div>
@stack('script')
</body>
</html>
I'm sure it's a simple mistake but i'm totally lost atm so any help is apreciated.
答案1
得分: 0
我忘记在我的布局中添加@LivewireScripts。感谢那些尝试帮助的人。
英文:
It was simple after all, I forgot to add @LivewireScripts to my layout. Thanks to those who tried to help.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论