m***@163.com
m***@163.com
  • 发布:2017-06-07 09:27
  • 更新:2017-09-13 10:28
  • 阅读:1509

指定顶部选项卡跳转

分类:MUI

看到一个帖子,但是不知道回复的什么意思,这边想继续咨询下(这是已经有的帖子http://ask.dcloud.net.cn/question/25309)
场景和上述的帖子场景一样
主页A:有几个入口,待付款,待发货,待收货,待评价等入口;
订单页面:上部有顶部滑动tab选项卡(基本上是搬得官方的):这边的部分代码如下:
mui.plusReady(function() {
var sData = plus.webview.currentWebview();
if(sData != null) {
if(sData.type != null) {
type = sData.type;
}
}
if(type == -1) {
document.getElementById("orders_all").className = "mui-control-item mui-
active";
// group.switchTab('orders_all.html');
} else if(type == 1) {
document.getElementById("orders_pendingpayment").className = "mui-
control-item mui-active";
// group.switchTab('orders_pendingpayment.html');
} else if(type == 2) {
document.getElementById("orders_shipmentpending").className = "mui-
control-item mui-active";
// group.switchTab('orders_shipmentpending.html');
} else if(type == 3) {
document.getElementById("orders_tobereceived").className = "mui-
control-item mui-active";
// group.switchTab('orders_tobereceived.html');
} else if(type == 4) {
document.getElementById("orders_pendingevaluation").className = "mui-
control-item mui-active";
// group.switchTab('orders_pendingevaluation.html');
} else if(type == 5) {
document.getElementById("orders_returngoods").className = "mui-control-
item mui-active";
// group.switchTab('orders_returngoods.html');
} else {
document.getElementById("orders_all").className = "mui-control-item mui-
active";
// group.switchTab('orders_all.html');
}
var accountId = 1;
var webview = plus.webview.currentWebview();
var group = new webviewGroup(webview.id, {
items: [{
id: "orders_all.html",
url: "orders_all.html",
extras: {
accountId: accountId
}
}, {
id: "orders_pendingpayment.html",
url: "orders_pendingpayment.html",
extras: {
accountId: accountId
}
}, {
id: "orders_shipmentpending.html",
url: "orders_shipmentpending.html",
extras: {
accountId: accountId
}
}, {
id: "orders_tobereceived.html",
url: "orders_tobereceived.html",
extras: {
accountId: accountId
}
}, {
id: "orders_pendingevaluation.html",
url: "orders_pendingevaluation.html",
extras: {
accountId: accountId
}
}, {
id: "orders_returngoods.html",
url: "orders_returngoods.html",
extras: {
accountId: accountId
}
}],

                onChange: function(obj) {  
                    var c = document.querySelector(".mui-control-item.mui-active");  
                    if(c) {  
                        c.classList.remove("mui-active");  
                    }  
                    document.querySelector(".mui-scroll .mui-control-item:nth-child(" +   
                                            (parseInt(obj.index) + 1) + ")").classList.add("mui-active");  
                }  
            });  

            mui(".mui-scroll").on("tap", ".mui-control-item", function(e) {  
                var wid = this.getAttribute("data-wid");  
                group.switchTab(wid);  
            });  

        });  

中间那一坨很简单的就是手动设置对应type的标签active
这样写没有用,虽然顶部active了,但是内容还是主页的,请教各位大神帮忙解决下!

2017-06-07 09:27 负责人:无 分享
已邀请:
n***@gmail.com

n***@gmail.com

能改变active样式 但是没有切换页面

  1. 创建group 过程 url有没有路径错误。
  2. 可能是 group.switchTab(wid); 这一步出了问题,打印一下wid 然后打断点看看你的 onChange 事件是怎么执行的。
w***@qq.com

w***@qq.com

请问楼主解决问题了吗?

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