12345678910111213141516171819202122232425262728293031 |
- <template>
- <div>
- <div>Watch1.0</div>
-
- <h3>我送了{{ flower }}花</h3>
- <button @click="sendFlower">再送一朵</button>
- </div>
- </template>
- <script lang="ts" setup>
- import { watch, ref } from "vue";
- let flower = ref(10);
- function sendFlower() {
- flower.value += 1;
- }
- watch(flower,(newValue,oldValue)=>{
- console.log(newValue,oldValue)
- },{
- deep: true,
- immediate: true
- })
- </script>
- <style lang="scss" scoped>
- </style>
|