bet

vue中watch数组或者对象

本秂侑毒 提交于 2019-11-27 21:23:25
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