【发布时间】:2018-07-17 04:06:39
【问题描述】:
谁能帮忙?我创建了一个选项卡步骤组件,但在进入下一步时遇到了问题,我创建了一种单击下一步按钮的方法,但它忽略了条件并进入最后一步。我的代码:
你好,有人可以帮忙吗?我创建了一个选项卡步骤组件,但在进入下一步时遇到了问题,我创建了一种单击下一步按钮的方法,但它忽略了条件并进入最后一步。我的代码:
verifyTabsCoherency(){
this.enabledTabs = [];
this.enabledTabs.push(
{ title: this.tabstepItem[0].title , icon: this.tabstepItem[0].icon, content: this.tabstepItem[0].icon, enable: this.tabstepItem[1].enable = true, selected: this.tabstepItem[1].enable = true }
);
this.enabledTabs.push(
{ title: this.tabstepItem[1].title, icon: this.tabstepItem[1].icon, content: this.tabstepItem[1].content, enable: this.tabstepItem[1].enable, selected: this.tabstepItem[1].selected }
);
if(this.customFilter.enableStation){
this.enabledTabs.push(
{ title: this.tabstepItem[2].title, icon: this.tabstepItem[2].icon, content: this.tabstepItem[2].content, enable: this.tabstepItem[2].enable, selected: this.tabstepItem[2].selected }
);
}
if(this.customFilter.enableUser) {
this.enabledTabs.push(
{ title: this.tabstepItem[3].title, icon: this.tabstepItem[3].icon, content: this.tabstepItem[3].content, enable: this.tabstepItem[3].enable, selected: this.tabstepItem[3].selected }
);
}
if(this.customFilter.enableAccess){
this.enabledTabs.push(
{ title: this.tabstepItem[3].title, icon: this.tabstepItem[4].icon, content: this.tabstepItem[4].content, enable: this.tabstepItem[4].enable, selected: this.tabstepItem[4].selected }
);
}
if(this.customFilter.Companys){
this.enabledTabs.push(
{ title: this.tabstepItem[3].title, icon: this.tabstepItem[5].icon, content: this.tabstepItem[5].content, enable: this.tabstepItem[5].enable, selected: this.tabstepItem[5].selected }
);
}
if(this.customFilter.Customers){
this.enabledTabs.push(
{ title: this.tabstepItem[3].title, icon: this.tabstepItem[6].icon, content: this.tabstepItem[6].content, enable: this.tabstepItem[6].enable, selected: this.tabstepItem[6].selected }
)
}
if(this.customFilter.Sections){
this.enabledTabs.push(
{ title: this.tabstepItem[7].title, icon: this.tabstepItem[7].icon, content: this.tabstepItem[7].content, enable: this.tabstepItem[7].enable, selected: this.tabstepItem[7].selected }
)
}
resolveDate() {
const myDateStart = new Date(this.dateStart);
const myDateEnd = new Date(this.dateEnd);
const myDateStartCompare = new Date(this.dateStartCompare);
const myDateEndCompare = new Date(this.dateEndCompare);
if ( this.dateStart && this.dateEnd ) {
return true;
} else { return false;}
}
resolveCarpark(){
const mycar = this.car.filter(car => car.checked === true);
if( mycar.length > 0 || this.selectedGroupsTree.length > 0){
return true;
}
else{ return false; }
}
resolveStations(){
const myStation = this.stations.filter(stations => stations.checked === true);
if( myStation.length > 0 ){
return true;
}
else{ return false; }
}
resolveTabItem ( indexTo: number, validateTo: boolean ) {
this.enabledTabs[indexTo].enable = validateTo;
this.enabledTabs[indexTo].selected = validateTo;
}
nextTab(){
if ( this.resolveDate() ) {
this.resolveTabItem(1, true);
} else if ( this.resolveCarpark() ) {
this.resolveTabItem(2, true);
}
}
【问题讨论】:
-
前进到最后一个标签是什么意思?好像你只有2个标签?第一个和第二个索引。
-
对不起,我刚刚删除了它。实际上有四个选项卡,当它是第一个索引并单击以转到下一个索引时,它会转到最后一个索引
-
很可能你的函数是这样的,除了最后一个,this.resolveCarpark() 在这种情况下不会返回 true。你确定他们返回的是真的吗?
-
然后它返回 true,激活选项卡并转到选项卡的最后一个索引。我认为这与if有关
-
好的,现在我发现您的代码有些奇怪。在您的 resolveTabItem() 中,它只会启用下一个选项卡。因此,当代码通过 nextTab() 的 if else 时,每个选项卡都将被启用并继续前进,直到最后一个。
标签: javascript arrays arraylist javascript-objects