zoukankan      html  css  js  c++  java
  • vue snippnets

    一、更新数组和对象

    官网link-数组更新检测/对象变更检测

    1 this.$set(currentObj, 'selectOption', res[currentTable][currentKey])
    2 
    3 this.$set(array, array.length, {
    4    id: this.ruleId++,
    5    leftValue: this.dmsObj.detailObj[dmsid].ruleLeft === 1 ? 1 : '>',
    6    rightValue: 0
    7 })

    二、watch obj

      watch: {
        dmsObj: {
          handler (newV, oldV) {
            this.indexList = {}
            let calNum = 0
            for (const key in this.dmsObj.detailObj) {
              if (this.dmsObj.detailObj[key]['showFlag']) {
                calNum += 1
                this.indexList[key] = calNum
              }
            }
            this.dmsObj.detailNum = calNum
          },
          deep: true
        }
      }
        'currentRecord.userType'(newV, oldV) {
          console.log('userType newV is ...', newV)
          if (this.pageMode === 'add') {
            this.localDmsData.base_info.res = []
            this.$forceUpdate()
          }
        },
     

    三、深拷贝

          if (this.currentOpObj.mode === 'add') {
            if (this.currentOpObj.parent) {
              const tmpSet = {
                relation: 1,
                arr: [_.cloneDeep(modalData)]
              }
              // opArr.push(tmpSet)
              // this.localDmsData.baseInfo.arr = new Array(...opArr)
    
              // this.$set(this.localDmsData.baseInfo, 'arr', _.cloneDeep(opArr))
              this.$set(opArr, opArr.length, tmpSet)
           
            } else {
              const index = this.currentOpObj.baseInfoIndex
              opArr[index].arr.push(_.cloneDeep(modalData))
            }
          }
  • 相关阅读:
    day14
    day13
    装饰器小题
    day12
    tes..
    1380 没有上司的舞会
    算法模板——KMP字符串匹配
    算法模板——Tarjan强连通分量
    3211: 花神游历各国
    1131: [POI2008]Sta
  • 原文地址:https://www.cnblogs.com/dhjy123/p/11804701.html
Copyright © 2011-2022 走看看