今天小编就为大家分享一篇Laravel-添加后台模板AdminLte的实现方法,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧
AdminLTE是一个很棒的单纯的由 HTML 和 CSS 构建的后台模板,在这片文章中,我将讲述如何将 AdminLTE 和 Laravel 优雅的整合在一起,而且我们可以通过 B来源gaodai#ma#com搞@@代~&码网ower 来及时的更新和管理 AdminLTE。
1、新建laravel项目
composer create-project laravel/laravel myapp --prefer-dist
2、使用前端包管理器添加AdminLte(可以使用npm或者yarn、bower),在项目根目录下执行如下命令:
yarn add admin-lte
会在项目根目录下看到,node_modules\admin-lte\
3、将admin-lte文件夹复制到public目录下,开始使用:
首先按照laravel模板的方式建立layouts基础样式模板 default.balde.php, 将admin-lte下的starter.html内容复制到default中,
并将头尾侧边栏等公用部分放入不同的子模板_header _footer _left中,如图:
最后的default模板代码:(注意修改好导入样式和js文件的路径)
<title>后台管理系统</title><!-- Tell the browser to be responsive to screen width --><!-- Bootstrap 3.3.6 --><!-- Font Awesome --><!-- Ionicons --><!-- Theme style --><!--[if lt IE 9]> <![endif]--> <div class="wrapper"> @include('admin.layouts._header') @include('admin.layouts._left') @yield('content') @include('admin.layouts._footer') @include('admin.layouts._tip') <div class="control-sidebar-bg"></div></div><!-- jQuery 2.2.3 --><!-- Bootstrap 3.3.6 --><!-- AdminLTE App -->
项目中的其他页面就可以继承使用layouts模板了:
@extends('admin.layouts.default') @section('content') <div class="content-wrapper"> <section class="content-header"> <h1> Page Header <small>首页管理</small></h1><ol class="breadcrumb"> <li><i class="fa fa-dashboard"></i> Level</li><li class="active">Here</li></ol></section><section class="content"> <div class='row'> <div class='col-md-6'> <!-- Box1 --><div class="box box-primary"> <div class="box-header with-border"> <h3 class="box-title">盒子一</h3><div class="box-tools pull-right"> <button class="btn btn-box-tool" title="Collapse"><i class="fa fa-minus"></i></button><button class="btn btn-box-tool" title="Remove"><i class="fa fa-times"></i></button></div></div><div class="box-body"> <table></table></div><div class="box-footer"> </div></div></div></div></section></div> @stop
想要使用admin-lte自带的任何样式,直接复制那部分的页面代码粘贴到需要的位置即可,
在本地电脑上直接打开admin-lte下index.html就可以查看到所有的样式效果
本例最后达到的效果如图:
以上这篇Laravel-添加后台模板AdminLte的实现方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持gaodaima搞代码网。
以上就是Laravel-添加后台模板AdminLte的实现方法的详细内容,更多请关注gaodaima搞代码网其它相关文章!