请问如何简化这段 if else

if (type == 1) {
    if (state == 0) {
      this.aaa(activeId)
    } else if (state == 1) {
      this.qqq(type)
      this.clickNum = 1
    }
  } else if (type == 2) {
    if (state == 0) {
      this.bbb(hasFollow, shopId)
    } else if (state == 1 && hasFollow == true) {
      this.qqq(type)
      this.clickNum = 2
    }
  } else if (type == 3) {
    if (state == 0 || state == 1) {
      this.ccc()
    }
  } else if (type == 4) {
    if (state == 0) {
      this.ddd(skuId)
    } else if (state == 1) {
      this.qqq(type)
      this.clickNum = 4
    }
  } else if (type == 5) {
    if (state == 0) {
      this.$emit('shareId')
    }
  }
待解决 悬赏分:80 - 离问题结束还有 341天14小时30分28秒
反对 0举报 0 收藏 0

我来回答

回答4