njnelson
njnelson
  • 发布:2014-10-17 16:34
  • 更新:2016-12-29 16:04
  • 阅读:5391

关于tabbar与子页面结合问题

分类:MUI

我描述一下问题,请了解的朋友帮忙解答一下:

1、新建了一个index,其中包括header、nav和content。
2、nav选项有4个,每个间的切换都是正常,并且content显示不同内容。

修改内容:

现在想在每个底部选项间切换时,每个选项对应的content显示一个由mui.init({所加载的子页面。

问题:

无论怎么改,只全局显示最后一个增加的mui.init({子页面,无法做到不同选项加载不同子页,查找相关文档没有提及,比较苦恼,请高手帮忙,谢谢!

附index.html代码:

{{{
<!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">  

    <link rel="stylesheet" href="css/mui.min.css">  
    <script src="js/mui.min.js"></script>  
    <script src="js/app.js"></script>  
    <style>  
        html,  
        body {  
            background-color: #efeff4;  
        }  
    </style>  
</head>  

<body>  

    <style>  
        .mui-control-content h3 {  
            padding-top: 100px;  
            text-align: center;  
        }  
    </style>  
    <nav class="mui-bar mui-bar-tab">  
        <a class="mui-tab-item mui-active" href="#ceshi1">  
            <span class="mui-icon mui-icon-phone"></span>  
            <span class="mui-tab-label">电话咨询</span>  
        </a>  
        <a class="mui-tab-item" href="#ceshi2">  
            <span class="mui-icon mui-icon-email"></span>  
            <span class="mui-tab-label">短信咨询</span>  
        </a>  
        <a class="mui-tab-item" href="#ceshi3">  
            <span class="mui-icon mui-icon-contact"></span>  
            <span class="mui-tab-label">通讯录</span>  
        </a>  
        <a class="mui-tab-item" href="#ceshi4">  
            <span class="mui-icon mui-icon-map"></span>  
            <span class="mui-tab-label">查看地图</span>  
        </a>  
    </nav>  
    <div class="mui-content">  
        <div id="ceshi1" class="mui-control-content mui-active">  
            <header class="mui-bar mui-bar-nav">  
                <h1 class="mui-title">测试1</h1>  
            </header>  
            <script>  
                mui.init({  
                    subpages: [{  
                        id: 'list',  
                        url: 'list.html',  
                        styles: {  
                            top: '48px',  
                            bottom: '48px',  
                            bounce: 'vertical'  
                                //scrollIndicator : "none"  
                        }  
                    }]  
                });  
            </script>  
        </div>  
        <div id="ceshi2" class="mui-control-content">  
            <header class="mui-bar mui-bar-nav">  
                <h1 class="mui-title">测试2</h1>  
            </header>  
            <script>  
                mui.init({  
                    swipeBack: false,  
                    subpages: [{  
                        id: 'list2',  
                        url: 'list2.html',  
                        styles: {  
                            top: '48px',  
                            bottom: '48px',  
                            bounce: 'vertical'  
                                //scrollIndicator : "none"  
                        }  
                    }]  
                });  
            </script>  
        </div>  
        <div id="ceshi3" class="mui-control-content">  
            <header class="mui-bar mui-bar-nav">  
                <h1 class="mui-title">测试3</h1>  
            </header>  
            <script>  
                mui.init({  
                    swipeBack: false,  
                    subpages: [{  
                        id: 'list3',  
                        url: 'list3.html',  
                        styles: {  
                            top: '48px',  
                            bottom: '48px',  
                            bounce: 'vertical'  
                                //scrollIndicator : "none"  
                        }  
                    }]  
                });  
            </script>  
        </div>  
        <div id="ceshi4" class="mui-control-content">  
            <header class="mui-bar mui-bar-nav">  
                <h1 class="mui-title">测试4</h1>  
            </header>  
            <<script>  
                mui.init({  
                    swipeBack: false,  
                    subpages: [{  
                        id: 'list4',  
                        url: 'list4.html',  
                        styles: {  
                            top: '48px',  
                            bottom: '48px',  
                            bounce: 'vertical'  
                                //scrollIndicator : "none"  
                        }  
                    }]  
                });  
            </script>  
        </div>  
        </div>  
</body>  

</html>
}}}

2014-10-17 16:34 负责人:无 分享
已邀请:
DCloud_UNI_CHB

DCloud_UNI_CHB

你定义了每个子页面的top、bottom,这些子页面会逐个覆盖,因此总显示你最后添加的子页面;

如果你想要实现webview模式选项卡,可参考hello mui中的源码示例,也可以直接参考:https://github.com/dcloudio/mui/blob/master/examples/hello-mui/examples/tab-webview-main.html

  • njnelson (作者)

    已解决,非常感谢!

    2014-10-18 17:52

b***@qq.com

b***@qq.com

我也想实现这样的,你有好的方法实现了吗?我在做纯wap网站,要手机各个浏览器可以打开的,如果用webview方法实现,浏览器还能打开不?

  • 赵梦欢

    浏览器下不支持webview,不过可以使用iframe做兼容处理,可以看看这个例子:https://rawgit.com/zhaomenghuan/mui-demo/master/example/tabbar-with-iframe/tab-webview-main.html

    2016-12-29 16:14

  • b***@qq.com

    回复 赵梦欢:好的~非常感谢!!!

    2016-12-29 17:05

  • b***@qq.com

    回复 赵梦欢:这个demo很好用,还想最后问一下iframe就可以使浏览器也打开webview方式的代码了么?

    2016-12-29 17:44

  • 赵梦欢

    回复 b***@qq.com: 不是,webview不能在普通浏览器下执行http://ask.dcloud.net.cn/docs/#//ask.dcloud.net.cn/article/113

    2016-12-29 17:46

  • b***@qq.com

    回复 赵梦欢:这样啊,那纯wap网站,要在各个浏览器实现底部导航栏切换是不同的页面肿么实现呀?

    2016-12-29 17:54

  • 愚者

    无量天尊

    2018-06-22 10:43

该问题目前已经被锁定, 无法添加新回复