1. <template>
    2. <div style="margin: 30px">
    3. {{ count }} <button @click="changeCount">clcik</button>
    4. </div>
    5. </template>
    6. <script>
    7. import { ref, watch } from "vue";
    8. export default {
    9. setup(props) {
    10. const count =ref(0);
    11. const changeCount = ()=>{
    12. count.value = count.value+10;
    13. }
    14. watch(count,(newVale,oldValue)=> {
    15. console.log(newVale,oldValue)
    16. })
    17. return {
    18. count,
    19. changeCount
    20. };
    21. },
    22. };
    23. </script>