監聽整個對象,使用watch就行
export default {  data() {    return {      a: {        b: 1,        c: 2      }    }  },  watch() {    a: {      handler(newVal, oldVal) {        console.log('監聽a整個對象的變化');      },      deep: true    }  }}監聽對象中具體屬性的變化,需要使用watch配合computed
export default {  data() {    return {      a: {        b: 1,        c: 2      }    }  },  watch() {    bChange() {      console.log('監聽a對象中b屬性的變化');    }  },  computed: {    bChange() {      return this.a.b;    }  }}新聞熱點
疑難解答