最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Vue開發(fā)之watch監(jiān)聽數(shù)組、對象、變量操作分析

 更新時間:2019年04月25日 10:40:09   作者:guanguan0_0  
這篇文章主要介紹了Vue開發(fā)之watch監(jiān)聽數(shù)組、對象、變量操作,結(jié)合實例形式分析了vue.js使用Watch針對數(shù)組、對象、變量監(jiān)聽相關(guān)操作技巧,需要的朋友可以參考下

本文實例講述了Vue開發(fā)之watch監(jiān)聽數(shù)組、對象、變量操作。分享給大家供大家參考,具體如下:

1.普通的watch

data() {
  return {
    frontPoints: 0
  }
},
watch: {
  frontPoints(newValue, oldValue) {
    console.log(newValue)
  }
}

2.數(shù)組的watch:深拷貝

data() {
  return {
    winChips: new Array(11).fill(0)
  }
},
watch: {
  winChips: {
    handler(newValue, oldValue) {
      for (let i = 0; i < newValue.length; i++) {
        if (oldValue[i] != newValue[i]) {
          console.log(newValue)
        }
      }
    },
    deep: true
  }
}

3.對象的watch

data() {
  return {
    bet: {
      pokerState: 53,
      pokerHistory: 'local'
    }
  }
},
watch: {
  bet: {
    handler(newValue, oldValue) {
      console.log(newValue)
    },
    deep: true
  }
}

4.對象的具體屬性的watch:

data() {
  return {
    bet: {
      pokerState: 53,
      pokerHistory: 'local'
    }
  }
},
computed: {
  pokerHistory() {
    return this.bet.pokerHistory
  }
},
watch: {
  pokerHistory(newValue, oldValue) {
    console.log(newValue)
  }
}

希望本文所述對大家vue.js程序設(shè)計有所幫助。

相關(guān)文章

最新評論

吉安市| 望城县| 定安县| 镇坪县| 鹤峰县| 平凉市| 鄄城县| 哈密市| 博野县| 化州市| 专栏| 济宁市| 孝昌县| 普定县| 乌鲁木齐县| 明星| 定远县| 石棉县| 自治县| 峨边| 临沂市| 丰镇市| 文水县| 通化县| 繁峙县| 湘西| 磐安县| 东乌| 平乡县| 新竹县| 离岛区| 光山县| 牡丹江市| 大余县| 海原县| 南丹县| 靖安县| 林甸县| 萨迦县| 阿鲁科尔沁旗| 石狮市|