watch监听ref的简单类型
<template> <div> {{refWatch}} <button @click="refWatch++">ref的变化</button> </div> </template> <script> import {ref,reactive,watch} from 'vue' export default { setup(){ // 1.ref的监听 - 简单数据 const refWatch = ref(0) watch(refWatch,(newV,oldV)=>{ console.log(newV,oldV) }) return { refWatch, } } } </script>
本文来自博客园,作者:杨建鑫,转载请注明原文链接:https://www.cnblogs.com/qd-lbxx/p/16620225.html