<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <div id="app">
    <button @click="change()">修改</button>
    <h2>姓： {{firstName}}</h2>
    <h2>名： {{lastName}}</h2>
    <h2>姓名: {{fullName}}</h2>

  </div>
  <script src="vue.js"></script>
  <script>
    var app = new Vue({
      el: "#app",
      data: {
        firstName: 'zhang',
        lastName: 'san',
        sex: '男'
      },
      methods: {
        change() {
          this.firstName = 'li'
        }
      },
      computed: {
        fullName: function () {
          console.log(333)
          return this.firstName + this.lastName
        }
      },
      watch: {
        firstName: function(){
          console.log('fffff')
        },
        lastName: function(){
          console.log('llllll')
        }
      }
      /* 
        在vue中 watch和computed都是用来观察数据变化的
        作用不同


        watch是响应式数据变化并且进行相应的操作
        computed是用来计算一些基于响应式数据的操作


        computed 是带有一定缓存的  当响应式数据没有变化的时候  computed 不会重新计算
      */
    })
  </script>
</body>

</html>