从page页面接口获取标签思考if与if else使用场景

前提:

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();
            });
          }

 

如果有更好的办法可以留言评论 ,谢谢

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值