开发web编辑器
原框架js,css,html
二、在数据库中,根据菜单的type类型,进行区分,在示例中,按照1,2,3的方式来定义菜单级别,修改JS,直接上代码,类型为2的则为三级菜单的父节点。生成菜单的方法:template: [ '
- ', '
- ', ' {{item.name}}', '', '', '{{item.name}}', '', '', ' ', ' ', '
三、根据模板中定义的html元素,进行处理点击的逻辑,直接上代码:$('#larry-nav-side').children('ul').find('li').each(function () { var $this = $(this); if ($this.find('dl').length > 0) { var $dd = $this.find('dd').each(function () { var $this = $(this); var flag = true; if($this.find('ol').length > 0){ $(this).on('click', function () { if(flag){ $(this).children().toggle(); $(this).find('a').removeAttr('style'); } flag=true; }); var $threeli =$this.children('ol').find('li').each(function(){ $(this).on('click', function () { var $a = $(this).children('a'); var href = $a.data('url'); var icon = $a.children('i:first').data('icon'); var title = $a.children('span').text(); var data = { href: href, icon: icon, title: title } navtab.tabAdd(data); flag=false; }); }); }else{ $(this).on('click', function () { var $a = $(this).children('a'); var href = $a.data('url'); var icon = $a.children('i:first').data('icon'); var title = $a.children('span').text(); var data = { href: href, icon: icon, title: title } navtab.tabAdd(data); }); } }); } else { $this.on('click', function () { var $a = $(this).children('a'); var href = $a.data('url'); var icon = $a.children('i:first').data('icon'); var title = $a.children('span').text(); var data = { href: href, icon: icon, title: title } navtab.tabAdd(data); }); } });
针对某些使用了layui的框架,未存在三级菜单的修改