我仿照例子里的pullfresh_with_tab, 将选项卡和下面的内容页JS添加,但是,添加完成后内容DIV不能滑动,点击上面的选项卡内容DIV也不切换。真的是不知道怎么弄了,求大神给看看。
<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 id="slider" class="mui-slider mui-fullscreen">
<div id="sliderSegmentedControl" class="mui-scroll-wrapper mui-slider-indicator mui-segmented-control mui-segmented-control-inverted">
<div id="tab_list" class="mui-scroll">
</div>
</div>
<div id="content_area" class="mui-slider-group">
</div>
</div>
</div>
mui.init();
//设置标签选项卡
var makeTab = function() {
var TAB = document.getElementById('tab_list');
for(var i = 1; i <= 2; i++) {
var _a = document.createElement('a');
if(i === 1) {
_a.className = 'mui-control-item mui-active';
} else {
_a.className = 'mui-control-item';
}
_a.href = '#item' + i + 'mobile';
_a.innerHTML = "ceshi"+i;
TAB.appendChild(_a);
}
}
var makeContent = function() {
var content_area = document.getElementById('content_area');
for(var i = 1; i <= 2; i++) {
var content = document.createElement('div');
content.id = 'item' + i + 'mobile';
if(i === 1) {
content.className = "mui-slider-item mui-control-content mui-active";
} else {
content.className = "mui-slider-item mui-control-content";
}
var content_1 = document.createElement('div');
content_1.id = 'scroll' + i;
content_1.className = 'mui-scroll-wrapper';
var content_2 = document.createElement('div');
content_2.className = 'mui-scroll';
var _ul = document.createElement('ul');
_ul.id = 'list' + i;
_ul.className = 'mui-table-view';
for(var j=0;j<3;j++){
var _li=document.createElement("li");
_li.className='mui-table-view-cell';
_li.innerHTML=i+'ceshi'+j;
_ul.appendChild(_li);
}
content_2.appendChild(_ul);
content_1.appendChild(content_2);
content.appendChild(content_1);
content_area.appendChild(content);
}
}
mui.ready(function() {
makeTab();
makeContent();
mui.init();
});
5 个回复
BoredApe - 有问题就会有答案。
动态添加需要重新初始化请参考文档http://dev.dcloud.net.cn/mui/ui/#gallery
OKOK (作者)
OKOK (作者)
求大神啊。。。
OKOK (作者)
有大神给看看的吗???
OKOK (作者)
根本没人吗?