成人午夜视频全免费观看高清-秋霞福利视频一区二区三区-国产精品久久久久电影小说-亚洲不卡区三一区三区一区

layuiAdmin利用json數(shù)據(jù)動(dòng)態(tài)生成左側(cè)菜單欄的方法

layuiAdmin單頁版根據(jù)后臺(tái)json數(shù)據(jù)動(dòng)態(tài)生成左側(cè)菜單欄

10年的覃塘網(wǎng)站建設(shè)經(jīng)驗(yàn),針對(duì)設(shè)計(jì)、前端、開發(fā)、售后、文案、推廣等六對(duì)一服務(wù),響應(yīng)快,48小時(shí)及時(shí)工作處理。營銷型網(wǎng)站建設(shè)的優(yōu)勢(shì)是能夠根據(jù)用戶設(shè)備顯示端的尺寸不同,自動(dòng)調(diào)整覃塘建站的顯示方式,使網(wǎng)站能夠適用不同顯示終端,在瀏覽器中調(diào)整網(wǎng)站的寬度,無論在任何一種瀏覽器上瀏覽網(wǎng)站,都能展現(xiàn)優(yōu)雅布局與設(shè)計(jì),從而大程度地提升瀏覽體驗(yàn)。創(chuàng)新互聯(lián)從事“覃塘網(wǎng)站設(shè)計(jì)”,“覃塘網(wǎng)站推廣”以來,每個(gè)客戶項(xiàng)目都認(rèn)真落實(shí)執(zhí)行。

使用模板方式加載菜單

lay-url=“菜單接口”

lay-headers=“將token帶入請(qǐng)求頭”,如果沒有,去掉就行

在模板中使用console.log 示例: {{# console.log(1) }}

layui.data(‘layuiAdmin’).token 調(diào)用本地存儲(chǔ)的token,token名需要和本地存儲(chǔ)對(duì)應(yīng)

json字段名不需要和這里的一樣,json字段名改變,模板里面也要相應(yīng)的修改

<div class="layui-side layui-side-menu">
  <div class="layui-side-scroll">
    <script type="text/html" template lay-url="https://easy-mock.com/mock/5c131015dada7b27ac3a5c36/titi/treemenu"
      lay-headers="{'x-auth-token': layui.data('layuiAdmin').token}"
      lay-done="layui.element.render('nav', 'layadmin-system-side-menu');" id="TPL_layout">
      <ul class="layui-nav layui-nav-tree" lay-shrink="all" id="LAY-system-side-menu"
        lay-filter="layadmin-system-side-menu">
        {{# 
          var path =  layui.router().path
          ,dataName = layui.setter.response.dataName;
           
          layui.each(d[dataName], function(index, item){ 
            var hasChildren = typeof item.list === 'object' && item.list.length > 0
            ,classSelected = function(){
              if(index == 0){
                return hasChildren ? 'layui-nav-itemed' : 'layui-this';
              }
              return '';
            }
            ,url = typeof item.href === 'string' ? item.href : item.name;
        }}
        <li data-name="{{ item.name || '' }}" data-jump="{{ item.href || '' }}"
          class="layui-nav-item {{ classSelected() }}">
          <a href="javascript:;" {{ hasChildren ? '' : 'lay-href="'+ url +'"' }} lay-tips="{{ item.title }}"
            lay-direction="2">
            <i class="layui-icon {{ item.icon }}"></i>
            <cite>{{ item.title }}</cite>
          </a>
          {{# if(hasChildren){ }}
          <dl class="layui-nav-child">
            {{# layui.each(item.list, function(index2, item2){ 
              var hasChildren2 = typeof item2.list == 'object' && item2.list.length > 0
              ,classSelected2 = function(){
                if(index==0){
                  return hasChildren2 ? 'layui-nav-itemed' : 'layui-this';
                }
                return '';
              }
              ,url2 = typeof item2.href === 'string' 
                ? item2.href 
              : [item.name, item2.name, ''].join('/');
            }}
            <dd data-name="{{ item2.name || '' }}" data-jump="{{ item2.href || '' }}"
              {{ classSelected2() ? ('class="'+ classSelected2() +'"') : '' }}>
              <a href="javascript:;" {{ hasChildren2 ? '' : 'lay-href="'+ url2 +'"' }}>{{ item2.title }}</a>
              {{# if(hasChildren2){ }}
              <dl class="layui-nav-child">
                {{# layui.each(item2.list, function(index3, item3){ 
                      var match = path[0] == item.name && path[1] == item2.name && path[2] == item3.name
                      ,url3 = typeof item3.href === 'string' 
                        ? item3.href 
                      : [item.name, item2.name, item3.name].join('/')
                    }}
                <dd data-name="{{ item3.name || '' }}" data-jump="{{ item3.href || '' }}"
                  {{ match ? 'class="layui-this"' : '' }}>
                  <a href="javascript:;" lay-href="{{ url3 }}">{{ item3.title }}</a>
                </dd>
                {{# }); }}
              </dl>
              {{# } }}
            </dd>
            {{# }); }}
          </dl>
          {{# } }}
        </li>
        {{# }); }}
      </ul>
    </script>
  </div>
</div>

后臺(tái)返回的json格式(示例)

{
  "code": 0
  ,"msg": ""
  ,"data": [{
    "title": "主頁"
    ,"icon": "layui-icon-home"
    ,"list": [{
      "title": "控制臺(tái)"
      ,"jump": "/"
    }, {
      "name": "homepage1"
      ,"title": "主頁一"
      ,"jump": "home/homepage1"
    }, {
      "name": "homepage2"
      ,"title": "主頁二"
      ,"jump": "home/homepage2"
    }]
  }, {
    "name": "component"
    ,"title": "組件"
    ,"icon": "layui-icon-component"
    ,"list": [{
      "name": "grid"
      ,"title": "柵格"
      ,"list": [{
        "name": "list"
        ,"title": "等比例列表排列"
      },{
        "name": "mobile"
        ,"title": "按移動(dòng)端排列"
      },{
        "name": "mobile-pc"
        ,"title": "移動(dòng)桌面端組合"
      },{
        "name": "all"
        ,"title": "全端復(fù)雜組合"
      },{
        "name": "stack"
        ,"title": "低于桌面堆疊排列"
      },{
        "name": "speed-dial"
        ,"title": "九宮格"
      }]
    }, {
      "name": "button"
      ,"title": "按鈕"
    }, {
      "name": "form"
      ,"title": "表單"
      ,"list": [{
        "name": "element"
        ,"title": "表單元素"
      },{
        "name": "group"
        ,"title": "表單組合"
      }]
    }, {
      "name": "nav"
      ,"title": "導(dǎo)航"
    }, {
      "name": "tabs"
      ,"title": "選項(xiàng)卡"
    }, {
      "name": "progress"
      ,"title": "進(jìn)度條"
    }, {
      "name": "panel"
      ,"title": "面板"
    }, {
      "name": "badge"
      ,"title": "徽章"
    }, {
      "name": "timeline"
      ,"title": "時(shí)間線"
    }, {
      "name": "anim"
      ,"title": "動(dòng)畫"
    }, {
      "name": "auxiliar"
      ,"title": "輔助"
    }, {
      "name": "layer"
      ,"title": "通用彈層"
      ,"list": [{
        "name": "list"
        ,"title": "功能演示"
      },{
        "name": "special-demo"
        ,"title": "特殊示例"
      },{
        "name": "theme"
        ,"title": "風(fēng)格定制"
      }]
    }, {
      "name": "laydate"
      ,"title": "日期時(shí)間"
      ,"list": [{
        "name": "demo1"
        ,"title": "功能演示一"
      },{
        "name": "demo2"
        ,"title": "功能演示二"
      },{
        "name": "theme"
        ,"title": "設(shè)定主題"
      },{
        "name": "special-demo"
        ,"title": "特殊示例"
      }]
    }, {
      "name": "table"
      ,"title": "表格"
      ,"list": [{
        "name": "simple"
        ,"title": "簡單數(shù)據(jù)表格"
      },{
        "name": "auto"
        ,"title": "列寬自動(dòng)分配"
      },{
        "name": "data"
        ,"title": "賦值已知數(shù)據(jù)"
      },{
        "name": "tostatic"
        ,"title": "轉(zhuǎn)化靜態(tài)表格"
      },{
        "name": "page"
        ,"title": "開啟分頁"
      },{
        "name": "resetPage"
        ,"title": "自定義分頁"
      },{
        "name": "toolbar"
        ,"title": "開啟頭部工具欄"
      },{
        "name": "totalRow"
        ,"title": "開啟合計(jì)行"
      },{
        "name": "height"
        ,"title": "高度最大適應(yīng)"
      },{
        "name": "checkbox"
        ,"title": "開啟復(fù)選框"
      },{
        "name": "radio"
        ,"title": "開啟單選框"
      },{
        "name": "cellEdit"
        ,"title": "開啟單元格編輯"
      },{
        "name": "form"
        ,"title": "加入表單元素"
      },{
        "name": "style"
        ,"title": "設(shè)置單元格樣式"
      },{
        "name": "fixed"
        ,"title": "固定列"
      },{
        "name": "operate"
        ,"title": "數(shù)據(jù)操作"
      },{
        "name": "parseData"
        ,"title": "解析任意數(shù)據(jù)格式"
      },{
        "name": "onrow"
        ,"title": "監(jiān)聽行事件"
      },{
        "name": "reload"
        ,"title": "數(shù)據(jù)表格的重載"
      },{
        "name": "initSort"
        ,"title": "設(shè)置初始排序"
      },{
        "name": "cellEvent"
        ,"title": "監(jiān)聽單元格事件"
      },{
        "name": "thead"
        ,"title": "復(fù)雜表頭"
      }]
    }, {
      "name": "laypage"
      ,"title": "分頁"
      ,"list": [{
        "name": "demo1"
        ,"title": "功能演示一"
      },{
        "name": "demo2"
        ,"title": "功能演示二"
      }]
    }, {
      "name": "upload"
      ,"title": "上傳"
      ,"list": [{
        "name": "demo1"
        ,"title": "功能演示一"
      },{
        "name": "demo2"
        ,"title": "功能演示二"
      }]
    }, {
      "name": "colorpicker"
      ,"title": "顏色選擇器"
    }, {
      "name": "slider"
      ,"title": "滑塊組件"
    }, {
      "name": "rate"
      ,"title": "評(píng)分"
    }, {
      "name": "carousel"
      ,"title": "輪播"
    }, {
      "name": "flow"
      ,"title": "流加載"
    }, {
      "name": "util"
      ,"title": "工具"
    }, {
      "name": "code"
      ,"title": "代碼修飾"
    }, {
      "name": "layim"
      ,"title": "即時(shí)聊天"
      ,"jump": "senior/im/"
    }]
  }, {
    "name": "template"
    ,"title": "頁面"
    ,"icon": "layui-icon-template"
    ,"list": [{
      "name": "personalpage"
      ,"title": "個(gè)人主頁"
      ,"jump": "template/personalpage"
    },{
      "name": "addresslist"
      ,"title": "通訊錄"
      ,"jump": "template/addresslist"
    },{
      "name": "caller"
      ,"title": "客戶列表"
      ,"jump": "template/caller"
    },{
      "name": "goodslist"
      ,"title": "商品列表"
      ,"jump": "template/goodslist"
    },{
      "name": "msgboard"
      ,"title": "留言板"
      ,"jump": "template/msgboard"
    },{
      "name": "search"
      ,"title": "搜索結(jié)果"
      ,"jump": "template/search"
    },{
      "name": "reg"
      ,"title": "注冊(cè)"
      ,"jump": "user/reg"
    },{
      "name": "login"
      ,"title": "登入"
      ,"jump": "user/login"
    },{
      "name": "forget"
      ,"title": "忘記密碼"
      ,"jump": "user/forget"
    },{
      "name": "404"
      ,"title": "404"
      ,"jump": "template/tips/404"
    },{
      "name": "error"
      ,"title": "錯(cuò)誤提示"
      ,"jump": "template/tips/error"
    }, {
      "name": ""
      ,"title": "內(nèi)嵌頁面"
      ,"spread": true
      ,"list": [{
        "name": ""
        ,"title": "百度一下"
        ,"jump": "/iframe/link/baidu"
      }, {
        "name": ""
        ,"title": "layui官網(wǎng)"
        ,"jump": "/iframe/link/layui"
      }, {
        "name": ""
        ,"title": "layuiAdmin官網(wǎng)"
        ,"jump": "/iframe/link/layuiAdmin"
      }]
    }]
  }, {
    "name": "app"
    ,"title": "應(yīng)用"
    ,"icon": "layui-icon-app"
    ,"list": [{
      "name": "content"
      ,"title": "內(nèi)容系統(tǒng)"
      ,"list": [{
        "name": "list"
        ,"title": "文章列表"
      },{
        "name": "tags"
        ,"title": "分類管理"
      },{
        "name": "comment"
        ,"title": "評(píng)論管理"
      }]
    },{
      "name": "forum"
      ,"title": "社區(qū)系統(tǒng)"
      ,"list": [{
        "name": "list"
        ,"title": "帖子列表"
      },{
        "name": "replys"
        ,"title": "回帖列表"
      }]
    },{
      "name": "message"
      ,"title": "消息中心"
    },{
      "name": "workorder"
      ,"title": "工單系統(tǒng)"
      ,"jump": "app/workorder/list"
    }]
  }, {
    "name": "senior"
    ,"title": "高級(jí)"
    ,"icon": "layui-icon-senior"
    ,"list": [{
      "name": "im"
      ,"title": "通訊系統(tǒng)"
    },{
      "name": "echarts"
      ,"title": "Echarts集成"
      ,"list": [{
        "name": "line"
        ,"title": "折線圖"
      },{
        "name": "bar"
        ,"title": "柱狀圖"
      },{
        "name": "map"
        ,"title": "地圖"
      }]
    }]
  }, {
    "name": "user"
    ,"title": "用戶"
    ,"icon": "layui-icon-user"
    ,"list": [{
      "name": "user"
      ,"title": "網(wǎng)站用戶"
      ,"jump": "user/user/list"
    }, {
      "name": "administrators-list"
      ,"title": "后臺(tái)管理員"
      ,"jump": "user/administrators/list"
    }, {
      "name": "administrators-rule"
      ,"title": "角色管理"
      ,"jump": "user/administrators/role"
    }]
  }, {
    "name": "set"
    ,"title": "設(shè)置"
    ,"icon": "layui-icon-set"
    ,"list": [{
      "name": "system"
      ,"title": "系統(tǒng)設(shè)置"
      ,"spread": true
      ,"list": [{
        "name": "website"
        ,"title": "網(wǎng)站設(shè)置"
      },{
        "name": "email"
        ,"title": "郵件服務(wù)"
      }]
    },{
      "name": "user"
      ,"title": "我的設(shè)置"
      ,"spread": true
      ,"list": [{
        "name": "info"
        ,"title": "基本資料"
      },{
        "name": "password"
        ,"title": "修改密碼"
      }]
    }]
  }, {
    "name": "get"
    ,"title": "授權(quán)"
    ,"icon": "layui-icon-auz"
    ,"jump": "system/get"
  }]
}

效果圖:

layuiAdmin利用json數(shù)據(jù)動(dòng)態(tài)生成左側(cè)菜單欄的方法

以上就是詳解layuiAdmin單頁版根據(jù)后臺(tái)json數(shù)據(jù)動(dòng)態(tài)生成左側(cè)菜單欄的詳細(xì)內(nèi)容,更多請(qǐng)關(guān)注創(chuàng)新互聯(lián)其它相關(guān)文章!

文章標(biāo)題:layuiAdmin利用json數(shù)據(jù)動(dòng)態(tài)生成左側(cè)菜單欄的方法
網(wǎng)頁路徑:http://jinyejixie.com/article10/jdoggo.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供微信小程序外貿(mào)網(wǎng)站建設(shè)、網(wǎng)站策劃、軟件開發(fā)、域名注冊(cè)、移動(dòng)網(wǎng)站建設(shè)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

外貿(mào)網(wǎng)站建設(shè)
平定县| 阳新县| 荣昌县| 中卫市| 郎溪县| 玉林市| 白玉县| 霍城县| 民丰县| 乌恰县| 岳普湖县| 安龙县| 陇川县| 隆昌县| 开封市| 壤塘县| 沾化县| 七台河市| 太谷县| 正镶白旗| 沾化县| 青海省| 双牌县| 伊春市| 得荣县| 固安县| 麻江县| 灵丘县| 明光市| 贵德县| 泰州市| 通海县| 迁西县| 瓦房店市| 枣阳市| 福海县| 五寨县| 肇源县| 新密市| 渝中区| 那曲县|