| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 | 
							- <!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: '男'
 
-       },
 
-       computed:{
 
-         fullName: function(){
 
-           console.log(333)
 
-           return this.firstName + this.lastName
 
-         }
 
-       },
 
-       methods:{
 
-         change(){
 
-           this.firstName = 'li'
 
-         }
 
-       },
 
-       watch:{
 
-         firstName: function(){
 
-           console.log(111)
 
-         },
 
-         lastName: function(){
 
-           console.log(222)
 
-         },
 
-         sex: function(){
 
-           console.log(555)
 
-         }
 
-         /* 
 
-         在Vue中 watch和computed都是用来观察数据变化的
 
-         作用不相同
 
-         watch是响应数据变化并且进行相应的操作
 
-         computed是用来计算一些基于响应式数据的操作
 
-         computed是带有一定缓存的  当响应式没有变化的时候
 
-         computed不会重新计算
 
-         
 
-         */
 
-       }
 
-     })
 
-   </script>
 
- </body>
 
- </html>
 
 
  |