Laravel:如何在选定的视图中包含外部链接



我已经在索引视图的<header>标签下包含了所有的css和js外部链接。

现在有一些外部链接,我想要load on selected views only

我可以在该视图上单独添加链接,但that link will go out of <head> tag

如何只从<header> tag of index view加载选定视图上的选定链接。

我试着

<head>
...other links
@if(View::exists('ispblade.calendar'))
@include('ispblade.calendar_links')
@endif 
</head>

但是它正在加载all views上的选定链接。

您需要使用stacks

在布局:

<head>
<!-- Head Contents -->
@stack('scripts')
</head>

在你看来:

@push('scripts')
<script src="/example.js"></script>
@endpush

https://laravel.com/docs/8.x/blade栈

最新更新