如何扩展布局而不覆盖布局部分中的脚本(Laravel 5.8)

时间:2019-04-26 11:01:15

标签: laravel laravel-5

这些应该足够简单,但是...

我有一个布局视图dashboard-layout.blade.php,其中:

@section('headscripts')
  <script src="{{ mix('/js/app.js') }}" defer></script>      
@show

以及扩展布局文件的billing.blade.php视图:

@extends('layouts.dashboard-layout')

@section('headscripts')
  @parent
  <script src="https://js.braintreegateway.com/web/dropin/1.17.2/js/dropin.min.js"></script>
@endsection

问题是,这仅输出第一个脚本...我在做什么错了?

1 个答案:

答案 0 :(得分:1)

您可以简单地使用@stack('name here')而不是@yield('name here')

并使用

@push('name here')
 // Add Your Script Here
@endpush

代替

@section('name here')
   // Scripts
@endsection

解决您的问题。