我是laravel的新手,所以这可能是一个愚蠢的问题,但我正在尝试使用partials减少代码中的重复,因为我的应用程序上的每个页面都有一个swiper幻灯片。
我首先在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>
作为字符串。
答案 0 :(得分:2)
@section('slide-image')
<div class="swiper-slide" style="src="{{asset('http://dialhousehotel.com/wp-content/uploads/2017/07/1.jpg')}}""></div>
<img >
@endsection
答案 1 :(得分:0)
你可以做到
@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