I have one file which contain 3 component. for example
<div1></div1>
<div2></div2>
<div3></div3>
@section('script')
<script>
/**
contains div1,div2,div3 dependent script
**/
</script>
Now i have kept separate blade.php for div
element
for example,
div1.blade.php
<div1>
</div1>
@section('script')
<script>
// this contain all the script related to div1 like ajax call and other things
</script>
div2.blade.php
<div2>
</div2>
@section('script')
<script>
// this contain all the script related to div2 like ajax call and other things
</script>
div3.blade.php
<div3>
</div3>
@section('script')
<script>
// this contain all the script related to div3 like ajax call and other things
</script>
Now i have included all this blade component into main component
main.blade.php
@section('content')
@include('div1.blade')
@include('div2.blade')
@include('div3.blade')
@endsection
@section('script')
//common script
@endsection
These all i have done and not getting how to load individual component script in main.blade.php
Try to use the below method to achieve your goal.
// main.blade.php
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
@yield('style')
<title>Hello, world!</title>
</head>
<body>
@yield('content')
@yield('script')
</body>
</html>
Now Extend the above main.blade.php file in your other files.
// other.blade.php
@extend('main')
@section('style')
//your all style files
@endsection
@section('content')
//your page content
@endsection
@section('script')
//your all scripts files
@endsection
I hope it helps.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.