Laravel5.1 搭建简单的社区(十)--实现下拉菜单
这一篇内容较为简单 主要是修改app.blade.php,实现下拉菜单需要引入jQuery和js:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Laravel App</title> <link rel="stylesheet" href="/css/bootstrap.css"> {{--引入fontawesome--}} <link rel="stylesheet" href="/css/font-awesome.css"> </head> <body> <div> <!-- Static navbar --> <nav class="navbar navbar-default"> <div class="container-fluid"> <div class="navbar-header"> <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar"> <span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> <a class="navbar-brand" href="#">Laravel-App</a> </div> <div id="navbar" class="navbar-collapse collapse"> <ul class="nav navbar-nav"> <li class="active"><a href="/">首页</a></li> </ul> <ul class="nav navbar-nav navbar-right"> @if(\Auth::check()) <li> <a id="dLabel" type="button" data-toggle="dropdown" aria-haspopup="true">{{ \Auth::user()->name }}</a> <!-- 增加下拉菜单 --> <ul class="dropdown-menu" aria-labelledby="dLabel"> <li><a href="#"><i class="fa fa-user"></i> 更换头像</a></li> <li><a href="#"><i class="fa fa-cog"></i> 更换密码</a></li> <li><a href="#"><i class="fa fa-heart"></i> 特别鸣谢</a></li> <li role="separator" class="divider"></li> <li><a href="/user/logout"><i class="fa fa-sign-out"></i> 退出登录</a></li> </ul> </li> {{-- 添加用户头像--}} <li><img src="{{ \Auth::user()->avatar }}" alt="64x64" class="img-circle" style="width: 50px; height: 50px";></li> @else <li><a href="/user/login">登 录</a></li> <li><a href="/user/register">注 册</a></li> @endif </ul> </div><!--/.nav-collapse --> </div><!--/.container-fluid --> </nav> </div> @yield('content') {{-- 引入js 和 jquery --}} <script src="//cdn.bootcss.com/jquery/3.0.0-alpha1/jquery.min.js"></script> <script src="//cdn.bootcss.com/bootstrap/3.3.5/js/bootstrap.min.js"></script> </body> </html>