vue 多规格商品的选择

    // 选择规格
    chooseitem (v, index, event, index3) {
      let that = this;
      let obj = {
        firstIndex: index,
        secondIndex: index3,
        value: v
      }
      if (that.selectArr.length == 0) {
        that.selectArr.push(obj)
      } else {
        let isFirst = that.selectArr.find(item => {
          return item.firstIndex == obj.firstIndex
        })
        let isSecond = that.selectArr.find(row => {
          return row.secondIndex == obj.secondIndex
        })
        if (isFirst == undefined && isSecond == undefined) {
          that.selectArr.push(obj)
        } else if (isFirst != undefined && isSecond == undefined) {
          that.selectArr.splice(that.selectArr.indexOf(isFirst), 1)
          that.selectArr.push(obj)
        } else if (isFirst = undefined && isSecond != undefined) {
          that.selectArr.push(obj)
        } else {
          that.selectArr.splice(that.selectArr.indexOf(isSecond), 1)
        }
      }
    },
posted @ 2020-11-02 11:28  小小小~  阅读(1399)  评论(0编辑  收藏  举报