最近基于laravel5.1做项目开发,后台菜单高亮,原来用jquery做菜单高亮,但发现到了新方法里就不奏效了,还是在定义变量在view层判断即可。
基类
定义两个变量,并共享到所有模板里
class BaseController extends Controller{ public $module; public $parent_module; public function __construct() { View::share('active',[$this->module=>'active']); View::share('parent_active',[$this->parent_module=>'active']); }}
继承的类
(赋值变量)
class ShopCategoryTagController extends BaseController{ public $module = 'cate_tag'; public $parent_module = 'parent_shop';
视图层
父级
<li class="treeview {{isset($parent_active['parent_shop']) ? $parent_active['parent_shop'] : ''}}">
子级
<li class="{{isset($active['cate_tag']) ? $active['cate_tag'] : ''}}"><a href="{{url('admin/shop_category_tag')}}">
效果:
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号