up
chenyc
2022-09-22 271f768b4766f70160de6272247d183e33f21de1
src/views/test.vue
@@ -1,4 +1,26 @@
<template>
    <div>hello  test page</div>
    <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>