Press "Enter" to skip to content

Laravel的blade模板引擎继承

父级 goods.special.create_base

 <div class="layui-form layui-layer-admin" >
     {{csrf_field()}}
      @yield('content_goods_special_type')
      @yield('content_goods_special')
      @yield('content_goods_special_name')
      @yield('content_goods_special_num')
</div>

父级–1 goods.special.bage.create

@extends('goods.special.create_base')

@section('content_goods_special_type')
    <input type="hidden" value="2" name="special_type">
@endsection

@section('content_goods_special_num')
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">数量</label>
            <div class="layui-input-inline">
                <input type="text" name="special_val"  placeholder="请输数量" autocomplete="off" class="layui-input">
            </div>
        </div>
    </div>
@endsection

子级 goods.special.card.create

@extends('goods.special.bage.create')

@section('content_goods_special_type')
    <input type="hidden" value="4" name="special_type">
@endsection

@section('content_goods_special_name')
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">道具名</label>
            <div class="layui-input-inline">
                <select name="special_id" lay-verify="required">
                    @foreach($itemType as $key => $val)
                        <option value="{{$key}}">{{$val}}</option>
                    @endforeach
                </select>
            </div>
        </div>
    </div>
@endsection

可以看出 laravel的模板可以多级继承、重写父级区块、这样就比较灵活

发表评论