我是靠谱客的博主 贤惠大门,最近开发中收集的这篇文章主要介绍mui实现3级折叠面板,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>Hello MUI</title>
        <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <!--标准mui.css-->
        <link rel="stylesheet" href="css/mui.min.css">
        <link rel="stylesheet" type="text/css" href="css/new_file.css" />
        <!--App自定义的css-->
        <!--<link rel="stylesheet" type="text/css" href="../css/app.css"/>-->
        <style>
            .mui-table-view-cell.mui-collapse-3 .mui-table-view .mui-table-view-cell:last-child:after, .mui-table-view-cell.mui-collapse-3 .mui-table-view:after, .mui-table-view-cell.mui-collapse-3 .mui-table-view:before { height:0 }
            .mui-table-view-cell.mui-collapse-3>.mui-navigate-right:after, .mui-table-view-cell.mui-collapse-3>.mui-push-right:after { content:'e581' }
            .mui-table-view-cell.mui-collapse-3.mui-active { margin-top:-1px }
            .mui-table-view-cell.mui-collapse-3.mui-active>.mui-navigate-right:after, .mui-table-view-cell.mui-collapse-3.mui-active>.mui-push-right:after { content:'e580' }
            .mui-table-view-cell.mui-collapse-3 .mui-collapse-content>.mui-input-group, .mui-table-view-cell.mui-collapse-3 .mui-collapse-content>.mui-slider { width:auto; height:auto; margin:-8px -15px }
            .mui-table-view-cell.mui-collapse-3 .mui-collapse-content>.mui-slider { margin:-8px -16px }
            .mui-table-view-cell.mui-collapse-3 .mui-table-view { display:none; margin-top:11px; margin-right:-15px; margin-bottom:-11px; margin-left:-15px; border:0 }
            .mui-table-view-cell.mui-collapse-3 .mui-table-view.mui-table-view-chevron { margin-right:-65px }
            .mui-table-view-cell.mui-collapse-3 .mui-table-view .mui-table-view-cell { padding-left:31px; background-position:31px 100% }
            .mui-collapse-content{margin-left: 30px;}
        </style>
    </head>
    <body>
        <header class="mui-bar mui-bar-nav">
            <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
            <h1 class="mui-title">人员选择</h1>
        </header>
        <div class="mui-content">
            <div class="mui-card">
                <ul class="mui-table-view">
                    
                    <li class="mui-table-view-cell mui-collapse-3">
                        <a class="mui-navigate-right" href="#">信贷审核人员</a>
                        <ul class="mui-table-view">
                            <li class="mui-table-view-cell mui-collapse-3">
                                <a class="mui-navigate-right" href="#">信贷审核人员</a>
                                <ul class="mui-table-view">
                                    <li class="mui-table-view-cell mui-collapse" id="list_li">
                    <a class="mui-navigate-right" href="#">信贷审核人员</a>
                    <div class="mui-collapse-content">
                        <div class="mui-input-al">
                        <div class="mui-input-row mui-checkbox" id="mui-input-row">
                            <img class="mui-input-row-tu" src="images/To-do-details/wer.png" alt="" />
                            <label class="mui-input-row-name">刘三</label>
                          <input name="checkbox1" type="checkbox" value="Item 1">
                        </div>
                        </div>
                    </div>
                </li>
                </ul>
                            </li>
                          
                        </ul>
                    </li>
                
                </ul>
            </div>
        </div>
        <script src="js/mui.min.js"></script>
        <script>
            mui.init({
                swipeBack:true //启用右滑关闭功能
            });
            var inputTap = false;
            mui('.mui-card').on('tap','.allSelect',function(){
                inputTap=true;
            });
            mui('.mui-card').on('tap','.mui-navigate-right',function(){
                if(inputTap){
                    inputTap=false;
                    return;
                }
                //记录状态
                var li=this.parentNode;
                var ul=this.parentNode.querySelector('.mui-table-view');
                var _style=ul.style.display;
                //关闭同级菜单
                var parent=this.parentNode.parentNode.children;
                for(var i=0;i<parent.length;i++){
                    if(!!parent[i].querySelector('.mui-table-view')){
                        parent[i].querySelector('.mui-table-view').style.display='';
                        removeClass(parent[i], 'mui-active');
                    }
                }
                //更改状态
                if(_style=='block'){
                    ul.style.display='';
                    removeClass(li,'mui-active');
                }else{
                    ul.style.display='block';
                    addClass(li,'mui-active');
                }
                //关闭下级子菜单
                var children=ul.children;
                for(var i=0;i<children.length;i++){
                    var child=children[i].querySelector('.mui-table-view');
                    if(!!child){
                        child.style.display='';
                        removeClass(children[i], 'mui-active');
                    }
                }
            });
            function hasClass(obj, cls) {  
                return obj.className.match(new RegExp('(\s|^)' + cls + '(\s|$)'));  
            }  
            function addClass(obj, cls) {  
                if (!this.hasClass(obj, cls)) obj.className += " " + cls;  
            }  
            function removeClass(obj, cls) {  
                if (hasClass(obj, cls)) {  
                    var reg = new RegExp('(\s|^)' + cls + '(\s|$)');  
                    obj.className = obj.className.replace(reg, '');  
                }  
            }  
        </script>
    </body>
</html>

最后

以上就是贤惠大门为你收集整理的mui实现3级折叠面板的全部内容,希望文章能够帮你解决mui实现3级折叠面板所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(29)

评论列表共有 0 条评论

立即
投稿
返回
顶部