前提:
page页面接口获取多个标签,如果需要在改页面只能添加一种类型就用 if(){}else if(){}
如果要添加多种则可以用if分代码块处理
举个例子:
当前页面 既有homeAppTabTag 又有 imagesTag就用 分段if ,如果业务只需要用一个ta就用 if(){}else if(){}
// 先清空 头部标题以及 标题栏 view
this.coms = null;
this.tabsService.getPageData(res, (pageData) => {
this.titleBar = pageData.titleBar;
if (pageData.coms[0] &&
pageData.coms[0].tagData.style === "tag.AppTabTagLogic" &&
pageData.coms[0].tagData.name === "homeAppTabTag") {
this.tagData = pageData.coms[0].tagData;
this.aWidth = 100 / this.tagData.data.length + "%";
this.showTopTab = true;
}
if (
pageData.coms[0] &&
pageData.coms[0].tagData.style === "tag.AppTabTagLogic" &&
pageData.coms[0].tagData.name === "imagesTag"
) {
this.subComs = pageData.coms;
// this.coms = undefined;
this.showSubTab = true;
this.showTopTab = false;
this.subTagData = this.subComs[0].tagData;
this.subAWidth = 100 / this.subTagData.data.length + "%";
}
this.coms = pageData.coms;
this.footerComs = pageData.footerComs;
this.isGrayBg = pageData.isGrayBg;
this.showRefresher = pageData.showRefresher;
this.showLoading = pageData.showLoading;
this.backgroundImg = pageData.backgroundImg;
this.showWaterImg = pageData.showWaterImg;
this.isFirst = false;
this.getCurrentToggleData();
});
}
如果有更好的办法可以留言评论 ,谢谢