@include
directive allows you to include a Blade view from within another view, like this :
@include('another.view')
Include CSS or JS from master layout
The asset
function generates a URL for an asset using the current scheme of the request (HTTP or HTTPS):
<link href="{{ asset('css/styles.css') }}" rel="stylesheet">
<script type="text/javascript" src="{{ asset('js/scripts.js') }}"></script>
If you are using versioned Mix file, you can also use mix()
function. It will returns the path to a versioned Mix file:
<link href="{{ mix('css/styles.css') }}" rel="stylesheet">
<script type="text/javascript" src="{{ mix('js/scripts.js') }}"></script>
Incude CSS or JS from sub-view, use @push()
.
layout.blade.php
<html>
<head>
<!-- push target to head -->
@stack('styles')
@stack('scripts')
</head>
<body>
<!-- or push target to footer -->
@stack('scripts')
</body>
</html
view.blade.php
@push('styles')
<link href="{{ asset('css/styles.css') }}" rel="stylesheet">
@endpush
@push('scripts')
<script type="text/javascript" src="{{ asset('js/scripts.js') }}"></script>
@endpush
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…