欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

AmazeUi Tree(樹(shù)形結(jié)構(gòu)) 應(yīng)用小結(jié)

  發(fā)布時(shí)間:2020-08-17 17:26:27   作者:weixin_34198762   我要評(píng)論
這篇文章主要介紹了AmazeUi Tree(樹(shù)形結(jié)構(gòu)) 應(yīng)用總結(jié),本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下

##這兩天工作比較忙,不過(guò)還是要總結(jié)相關(guān)的坑,希望兄弟們要謹(jǐn)慎應(yīng)用AmazeUI 里邊自帶的樹(shù)形結(jié)構(gòu)插件

##然后我簡(jiǎn)單說(shuō)下我們公司前端應(yīng)用:UI框架為AmazeUI(俗稱妹子),交互框架為JQ。

##如果你公司對(duì)于樹(shù)形結(jié)構(gòu)這邊要求不要求有點(diǎn)擊事件,只是純顯示那么你可以繼續(xù)向下看,如果要求樹(shù)形結(jié)構(gòu)支持勾選,支持拖拽等等...我建議你直接點(diǎn)擊退出,去用Ztree吧

第一步:基本引入

<link rel="stylesheet" href="assets/css/amazeui.tree.min.css">
 
  <ul class="am-tree" id="tree">
                   <!--以下第一個(gè)li標(biāo)簽如果設(shè)計(jì)沒(méi)有子級(jí)結(jié)構(gòu),可以屏蔽-->
                    <li class="am-tree-branch am-hide" data-template="treebranch">
                        <div class="am-tree-branch-header">
                            <button class="am-tree-branch-name">
                                <span class="am-tree-icon am-tree-icon-folder"></span>
                                <span class="am-tree-label"></span>
                            </button>
                        </div>
                        <ul class="am-tree-branch-children"></ul>
                        <div class="am-tree-loader"><span class="am-icon-spin am-icon-spinner"></span></div>
                    </li>
                    <li class="am-tree-item am-hide" data-template="treeitem">
                        <button class="am-tree-item-name">
                            <span class="am-tree-icon am-tree-icon-item"></span>
                            <span class="am-tree-label"></span>
                        </button>
                    </li>
                </ul>
<script src="assets/js/amazeui.tree.min.js"></script>

第二步:邏輯書寫(可新建JS書寫)

/*****粗加工后臺(tái)數(shù)據(jù)(給單條數(shù)據(jù)增加了id,和pid,type,title),如果后臺(tái)數(shù)據(jù)返回的直接帶有層級(jí)結(jié)構(gòu)的數(shù)據(jù)直接跳過(guò)這個(gè)步驟)
 *  for(i=0;i<odata.length;i++){
                    if(odata[i].level>=2){
                        //data[i].frameMenuStr
                        //截取倒數(shù)后兩個(gè)"."后邊的字符串/
                        let arr =["a","b","c","d","e","f","g","h","i"];
                        let str = odata[i].frameMenuStr;//當(dāng)前數(shù)據(jù)ID
                        odata[i].id= arr[odata[i].level-1]+str.substring(str.lastIndexOf(".")+1);
                        let j =str.lastIndexOf(".");//當(dāng)前數(shù)據(jù)父節(jié)點(diǎn)ID
                        odata[i].pid= arr[odata[i].level-2]+str.substring(str.lastIndexOf(".",j-1),str.lastIndexOf("."));
                        odata[i].title = odata[i].menuName;
                        odata[i].type = 'item';
                    }else{
                       odata[i].id = "a"+odata[i].frameMenuStr;
                       odata[i].title = odata[i].menuName;
                       odata[i].type = 'folder';
                       //odata[i].pid = "00000000"; 
                   }
                }
 * ********/
 /*******
 * 
 * data:灌入的數(shù)據(jù)(后臺(tái)返回的值要為有id和pid)
 * dom 所要綁定的區(qū)域id
 * callbackfun:回調(diào)函數(shù)
 * 范例:
function bindTree(data,dom,callbackfun){
    /************核心應(yīng)用:數(shù)組操作******************/
    let tree = data;
    var treeMaps = {};
    tree.forEach(function (value, index) {
       treeMaps[value.id] = value;
    })
    var data = [];
    tree.forEach(function (value, index) {
        var parent = treeMaps[value.pid]
        if (parent !== undefined) {
            if (parent.products === undefined) {
            parent.products = []
            }
            parent.products.push(value)
        } else {
            data.push(value);
        }
    })
    /***************以上這段代碼是二次加工數(shù)據(jù)為的讓之前沒(méi)有層級(jí)結(jié)構(gòu)的數(shù)據(jù),加工成有層級(jí)結(jié)構(gòu)的數(shù)據(jù)結(jié)構(gòu)********************/
    dom.tree({
        dataSource:function(options, callback) {
            // 模擬異步加載
            let num = 0;//通過(guò)num值操作區(qū)分(這是個(gè)坑一定要用這種方法,不能用data||options.products)
            if(num==0){
                setTimeout(function() {
                  callback({data: data});//初始顯示最高級(jí)別數(shù)據(jù)
                   num++;
                }, 400);
               
            }else{
                setTimeout(function() {
                  callback({data: options.products});//點(diǎn)擊節(jié)點(diǎn)顯示的數(shù)據(jù)
                }, 400);
            }
          },
        multiSelect: false,
        cacheItems: true,
        folderSelect: false,
    });
    dom.on('selected.tree.amui', function (event, data) {
        // do something with data: { selected: [array], target: [object] }
        //  console.log(data);
        // console.log(event);
         uuid = data.target.menuId;
         resData = data.target;
         if(callbackfun || typeof callbackfun != 'undefined' || callbackfun != undefined){
            return callbackfun(uuid);
          }
    });
    dom.tree("discloseAll");//這個(gè)函數(shù)暫時(shí)不起作用。
 }
 
 /**直接調(diào)用函數(shù)*/
 bindTree(odata,$("#tree"),function(){console.log("-------")});
 
 備注:
 
    //dom.tree("destroy");//數(shù)據(jù)更新我調(diào)用這個(gè)函數(shù)。但是一旦調(diào)用,直接所有dom結(jié)構(gòu)都沒(méi)有了,所以你要向之前綁定數(shù)據(jù)的地方重新灌入dom結(jié)構(gòu)。
     /***********插件結(jié)構(gòu)重新繪制***************/
    //  let str = "";
    //  str+='<li class="am-tree-branch am-hide" data-template="treebranch">';
    //     str+='<div class="am-tree-branch-header">';
    //         str+='<button class="am-tree-branch-name">';
    //         str+='<span class="am-tree-icon am-tree-icon-folder"></span>';
    //         str+='<span class="am-tree-label"></span>';
    //         str+='</button>';
    //     str+='</div>';
    //     str+='<ul class="am-tree-branch-children"></ul>';
    //     str+='<div class="am-tree-loader"><span class="am-icon-spin am-icon-spinner"></span></div>';
    //  str+='</li>';
    //  str+='<li class="am-tree-item am-hide" data-template="treeitem">';
    //     str+='<button class="am-tree-item-name">';
    //     str+='<span class="am-tree-icon am-tree-icon-item"></span>';
    //     str+='<span class="am-tree-label"></span>';
    //     str+='</button>';
    //  str+='</li>';
    //  dom.append(str);

##參考文章:

http://tech.yunyingxbs.com/article/detail/id/350.html
http://amazeui.github.io/tree/docs/demo.html

總結(jié)

到此這篇關(guān)于AmazeUi Tree(樹(shù)形結(jié)構(gòu)) 應(yīng)用總結(jié)的文章就介紹到這了,更多相關(guān)AmazeUi Tree樹(shù)形結(jié)構(gòu)內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持腳本之家!

相關(guān)文章

  • AmazeUI 折疊面板的實(shí)現(xiàn)代碼

    這篇文章主要介紹了AmazeUI 折疊面板的實(shí)例代碼,本文通過(guò)實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2020-08-17
  • AmazeUI框架搭建的方法步驟(圖文)

    這篇文章主要介紹了AmazeUI框架搭建的方法步驟(圖文),文中通過(guò)圖文介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)
    2020-08-17
  • AmazeUI 面板的實(shí)現(xiàn)示例

    這篇文章主要介紹了AmazeUI 面板的實(shí)現(xiàn)示例,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2020-08-17
  • AmazeUI 列表的實(shí)現(xiàn)示例

    這篇文章主要介紹了AmazeUI 列表的實(shí)現(xiàn)示例,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2020-08-17
  • AmazeUI導(dǎo)航的示例代碼

    這篇文章主要介紹了AmazeUI導(dǎo)航的示例代碼,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2020-08-14
  • AmazeUI中各種的導(dǎo)航式菜單與解決方法

    這篇文章主要介紹了AmazeUI中各種的導(dǎo)航式菜單與解決方法,本文通過(guò)實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2020-08-19

最新評(píng)論