有没有办法将 laravel 与滑动滑块结合起来

Is there a way to incorporate a laravel with a swiper slider


我是 laravel 的新手,所以这可能是一个愚蠢的问题,但我正在尝试使用部分代码减少代码中的重复,因为我的应用程序上的每个页面都有一个滑动幻灯片。

我首先在 slider.blade.php 中创建了一个部分:

<div class="swiper-container">
    <div class="swiper-wrapper">
        @yield('slide-image')
    </div>

    <div class="swiper-pagination swiper-pagination-white"></div>

    <div class="swiper-button-next swiper-button-white"></div>
    <div class="swiper-button-prev swiper-button-white"></div>
</div>

然后我将部分合并到 main.blade.php 文件中。

<!DOCTYPE html>
<html lang="en">

@include('partials._head')
<body>

@include('partials._pageloader')
@include('partials._navbar')

@include('partials._slider') <!---- Here  ---->
@yield('content')


@include('partials._scrolltotop')   

@include('partials._footer')

@include('partials._bottom')


</body>

</html>

要在首页添加幻灯片,例如已添加滑块图片部分。

@extends('main')

@section('title', 'Dialhouse Hotel')
@section('slide-image', 'div class="swiper-slide" style="<img src="http://dialhousehotel.com/wp-content/uploads/2017/07/1.jpg" alt="project-1" heigth="360px" width="360px">"></div>')
@section('content')



    @include('partials._contactform')

    @include('partials._googlemaps')

@endsection   

但是,问题是图像没有出现在页面上。它输出 <div class="swiper-slide" style="<img src="http://dialhousehotel.com/wp-content/uploads/2017/07/1.jpg" alt="project-1" heigth="360px" width="360px">"></div> 作为字符串。

你可以做到

@section('slide-image')

    <div class="swiper-slide" style="<img src="http://dialhousehotel.com/wp-content/uploads/2017/07/1.jpg" alt="project-1" heigth="360px" width="360px">"></div>

@endsection
@section('slide-image')
    <div class="swiper-slide" style="src="{{asset('http://dialhousehotel.com/wp-content/uploads/2017/07/1.jpg')}}""></div>
<img >
@endsection