簡體   English   中英

Laravel @section 似乎不起作用

[英]Laravel @section Does not seem to be working

我有一個名為dashboard.blade.php的 Blade,它是這樣的:

@extends( 'frontend.dashboard_main' )

@section('title')  Profile  @endsection
@section('style')
   SOME CUSTOM STYLES
@endsection

dashboard.blade.php是這樣的:

@include( 'frontend.header' )
...

header.blade.php ,我添加了這些:

<head>
<title>@yield('title')</title>
@yield('style')
...

但現在的問題是,一些自定義樣式似乎不起作用, @yield('style')不加載 css 樣式。

所以如果你知道這里出了什么問題,請告訴我......

用於在擴展視圖中包含cssjs文件。最好使用堆棧而不是產量

內部frontend/dashboard_main

 <header>
other css files and meta
@stack('styles')
</header>

並在擴展視圖中

@push('styles')
   <style>

</style>
@endpush

參考: https : //laravel.com/docs/5.8/blade#stacks

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM