## 使用模板继承 先在/resources/views/admin下新建一个布局模板 base.blade.php ``` ~~~ <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> <title>{{$title}} - {{config('web.web_name')}}</title> <meta name="csrf-token" content="{{csrf_token()}}"> <link rel="stylesheet" href="{{asset('/static/common/layui/css/layui.css')}}?v={{$version}}"> <link rel="stylesheet" href="{{asset('/static/admin/css/style.css')}}?v={{$version}}"> <script src="{{asset('/static/common/layui/layui.js')}}?v={{$version}}"></script> <script src="{{asset('/static/common/js/jquery-3.3.1.min.js')}}?v={{$version}}"></script> <script src="{{asset('/static/common/js/vue.min.js')}}?v={{$version}}"></script> <script src="{{asset('/static/common/js/axios.min.js')}}?v={{$version}}"></script> @yield('style') </head> <body> <div id="app"> <!--顶栏--> <header> <h1 v-text="webname"></h1> <div class="breadcrumb"> <i class="layui-icon">&#xe715;</i> <ul> <li v-for="vo in address"> <a v-text="vo.name" :href="vo.url" ></a> <span>/</span> </li> </ul> </div> </header> <div class="main" id="app"> <!--左栏--> <div class="left"> <ul class="cl" > <!--顶级分类--> <li v-for="vo,index in menu" :class="{hidden:vo.hidden}"> <a href="javascript:;" :class="{active:vo.active}" @click="onActive(index)"> <i class="layui-icon" v-html="vo.icon"></i> <span v-text="vo.name"></span> <i class="layui-icon arrow" v-show="vo.url.length==0">&#xe61a;</i> <i v-show="vo.active" class="layui-icon active">&#xe623;</i> </a> <!--子级分类--> <div v-for="vo2,index2 in vo.list"> <a href="javascript:;" :class="{active:vo2.active}" @click="onActive(index,index2)" v-text="vo2.name"></a> <i v-show="vo2.active" class="layui-icon active">&#xe623;</i> </div> </li> </ul> </div> <!--右侧--> <div class="right"> <!--你的内容这里面--> @yield('body') </div> </div> </div> <script type="text/javascript"> var webname = '{{config("web.web_name")}}'; var menuUrl = '/static/data/menu.json'; </script> <script src="{{asset('/static/admin/js/script.js')}}?v={{$version}}"></script> @yield('script') </body> </html> ~~~ ``` 然后新建后面首页模板 /resources/views/admin/index.blade.php ``` ~~~ <!--引入base--> @extends('admin.base') <!--独立页面的css,用不到可以删除--> @section('style') <style> .right h2{ margin: 10px 0; } .right li{ margin-bottom: 10px; } </style> @endsection <!--独立页面的js,用不到可以删除--> @section('script') <script> //... </script> @endsection <!--这里是你的页面内容--> @section('body') <blockquote class="layui-elem-quote"> <h2>QAdmin 轻量级后台模板</h2> <p>基于layui框架与Vue.js构建</p> <p>轻量不复杂 简洁不简单</p> </blockquote> <div class="layui-row"> <div class="layui-col-md4"> <div class="layui-card"> <div class="layui-card-header"><h2>支持我们</h2></div> <div class="layui-card-body" style="height: 250px;"> <ul> <li>如果您认为QAdmin对你有所帮助,你可以扫描以上二维码支持我们</li> <li>您的支持,将会出现在我们官网展现</li> <li><img height="180" src="static/admin/img/pay.png" /></li> </ul> </div> </div> </div> <div class="layui-col-md4"> <div class="layui-card"> <div class="layui-card-header"><h2>QAdmin 介绍</h2></div> <div class="layui-card-body" style="height: 250px;"> <ul> <li>QAdmin 是一个轻量级的后台模板,基于layui框架</li> <li>风格简洁简单,中小型项目首选</li> <li>不管你是初级还是高级工程师,都有可以快速上手</li> <li>QAdmin是由vue混合式开发,可以在模板任意使用jq或vue/layui</li> <li>当前版本: v1.0</li> <li><b>关注官网或github随时下载最新版</b></li> <li> <a href="http://www.qadmin.net/" target="_blank" class="layui-btn layui-btn-ms">进入官网</a> <a href="https://github.com/aa24615/qadmin" target="_blank" class="layui-btn layui-btn-ms layui-btn-danger">github</a> </li> </ul> </div> </div> </div> <div class="layui-col-md4"> <div class="layui-card"> <div class="layui-card-header"><h2>QAdmin 特点</h2></div> <div class="layui-card-body" style="height: 250px;"> <ul> <li>轻量级</li> <li>简洁直爽</li> <li>基于layui框架,上手快</li> <li>支持jq/vue/layui</li> <li>...</li> </ul> </div> </div> </div> </div> <div class="layui-row"> <div class="layui-col-md9" style="padding-right: 20px"> <h2>最新会员</h2> <table class="layui-table layui-form"> <thead> <tr> <th><a href="?/admin/user/index/order/uid.html">UID</a></th> <th>手机</th> <th>用户名</th> <th>昵称</th> <th>邮箱</th> <th><a href="?/admin/user/index/order/reg_time.html">注册时间</a></th> <th><a href="?/admin/user/index/order/login_time.html">登录时间</a></th> <th><a href="?/admin/user/index/order/login.html">登录次数</a></th> </tr> </thead> <tbody> <tr class="id36567"> <td>36567</td> <td>15912345678</td> <td>YY187919</td> <td></td> <td>YY187919@flash127.com</td> <td>2019-04-01 11:44:20</td> <td>2019-04-01 11:44:20</td> <td>7</td> </tr> <tr class="id36567"> <td>36567</td> <td>15912345678</td> <td>YY187919</td> <td></td> <td>YY187919@flash127.com</td> <td>2019-04-01 11:44:20</td> <td>2019-04-01 11:44:20</td> <td>7</td> </tr> <tr class="id36567"> <td>36567</td> <td>15912345678</td> <td>YY187919</td> <td></td> <td>YY187919@flash127.com</td> <td>2019-04-01 11:44:20</td> <td>2019-04-01 11:44:20</td> <td>7</td> </tr> <tr class="id36567"> <td>36567</td> <td>15912345678</td> <td>YY187919</td> <td></td> <td>YY187919@flash127.com</td> <td>2019-04-01 11:44:20</td> <td>2019-04-01 11:44:20</td> <td>7</td> </tr> <tr class="id36567"> <td>36567</td> <td>15912345678</td> <td>YY187919</td> <td></td> <td>YY187919@flash127.com</td> <td>2019-04-01 11:44:20</td> <td>2019-04-01 11:44:20</td> <td>7</td> </tr> <tr class="id36567"> <td>36567</td> <td>15912345678</td> <td>YY187919</td> <td></td> <td>YY187919@flash127.com</td> <td>2019-04-01 11:44:20</td> <td>2019-04-01 11:44:20</td> <td>7</td> </tr> </tbody> </table> </div> <div class="layui-col-md3"> <h2>会员统计</h2> <table class="layui-table layui-form"> <tr> <th>今天登录</th> <td>555</td> </tr> <tr> <th>昨天登录</th> <td>5552</td> </tr> <tr> <th>会员总数</th> <td>224555</td> </tr> <tr> <th>月活跃数</th> <td>55885</td> </tr> <tr> <th>季活跃数</th> <td>5485885</td> </tr> <tr> <th>vip用户</th> <td>65885</td> </tr> <tr> <th>过期vip</th> <td>525885</td> </tr> </table> </div> </div> @endsection ~~~ ``` 然而你以后新建的页面,只需引用以下代码即可 ``` <!--引入base--> @extends('admin.base') <!--独立页面的css,用不到可以删除--> @section('style') <style> .right h2{ margin: 10px 0; } .right li{ margin-bottom: 10px; } </style> @endsection <!--独立页面的js,用不到可以删除--> @section('script') <script> //... </script> @endsection <!--这里是你的页面内容--> @section('body') ```