데이터를 감시, 추적한다.

<template>
  <h1 @click="changeMessage">
    {{ msg }}
  </h1>
  <h1> {{ reverseMessage }} </h1>
</template>

<script>
export default {
  data() {
    return {
      msg: 'Hello?'
    }
  },
  computed: {
  reverseMessage() {
    return this.msg.split('').reverse().join('')
    }
  },
  watch: {
// newValue 와 같이 첫번째 매개변수로 변경된 값을 사용할 수 있다.
    msg(newValue) {
      console.log('msg:', newValue)
    },
    reverseMessage() {
      console.log('rM',this.reverseMessage)
    }
  },
  methods: {
    changeMessage() {
      this.msg = 'Good!'
    }
  }
}
</script>