js写的tab轮播根据下拉框改变,下拉框选1秒时,tab1秒轮播,选2秒时,2秒轮播。。。下面这样写有什么问题吗,我这样写出来的效果是只有第一次选的有效果,就是如果我第一次选5秒的话他就可以5秒轮播,然后我再选其他时间后tab块就不规则乱跳了;如果我第一次选2秒的话他可以2秒轮播,然后再选其他时间有乱跳了 var b = _g().getWidgetByName("pp").getValue(); // 获取下拉控件的值 console.log("获取参数",b);function fn() { //var a=this.options.form.getWidgetByName("pp").getValue();//取实际值 //var b = Widget.getValue(); var aa = _g().getWidgetByName("tabpane0").getShowIndex(); if(aa == 2) { _g().getWidgetByName('tabpane0').showCardByIndex(0); } else { _g().getWidgetByName('tabpane0').showCardByIndex(aa + 1); } console.log("轮播");};//var set1 = setInterval(fn, 1000);//var set2 = setInterval(fn, 2000);//var set3 = setInterval(fn, 3000);//var set4 = setInterval(fn, 5000);function set1() { set1 = setInterval(fn, 1000); console.log("1秒轮播");}function stop1() { clearInterval(set1); console.log("清除1秒轮播");}function set2() { set2 = setInterval(fn, 2000); console.log("2秒轮播");}function stop2() { clearInterval(set2); console.log("清除2秒轮播");}function set3() { set2 = setInterval(fn, 3000); console.log("3秒轮播");}function stop3() { clearInterval(set3); console.log("清除3秒轮播");}function set5() { set5 = setInterval(fn, 5000); console.log("5秒轮播");}function stop5() { clearInterval(set5); console.log("清除5秒轮播");}setTimeout(function() {if(b==1000) { stop2(); stop3(); stop5(); set1(); console.log(11,b);}else if (b==2000) { stop1(); stop3(); stop5(); set2(); console.log(22,b);}else if (b==3000) { stop2(); stop1(); stop5(); set3(); console.log(33,b);}else if (b==5000) { stop2(); stop3(); stop1(); set5(); console.log(55,b); }}, 1000); //轮播间隔