1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
| <template>
| <div>hello test page{{content}}</div>
| <div>{{data.a}}</div>
| <button @click="butclick">点击</button>
| </template>
| <script lang="ts" setup>
| import {ref,reactive,watchEffect,watch} from 'vue'
| const data=reactive({
| a:'chenyinc',
| h:'dadsad'
| })
| const butclick=()=>{
| data.a='你好'
| content.value='haha'
| }
| const content=ref('content')
| watchEffect(()=>{
| const x1=data.a
| console.log('watchEffect所指定的回调执行了',x1)
| })
| watch(content,(newValue,oldValue)=>{
| console.log(newValue,oldValue,'变化了')
| })
|
| </script>
|
|