国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 語言 > JavaScript > 正文

Vue開發之watch監聽數組、對象、變量操作分析

2024-05-06 15:40:10
字體:
來源:轉載
供稿:網友

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

1.普通的watch

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

2.數組的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程序設計有所幫助。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表

圖片精選

主站蜘蛛池模板: 瑞昌市| 宁国市| 屏东县| 宿州市| 卓尼县| 乐都县| 枣庄市| 云浮市| 平邑县| 维西| 阿坝县| 乌审旗| 公安县| 龙口市| 新密市| 元谋县| 临澧县| 莆田市| 墨江| 平江县| 新宁县| 安顺市| 湖州市| 黎平县| 当涂县| 宣武区| 宿州市| 和龙市| 金沙县| 长泰县| 广水市| 马尔康县| 马边| 阜阳市| 合水县| 竹山县| 渭南市| 临猗县| 保康县| 桐梓县| 西乌|