当前位置: 首页 > Web前端 > JavaScript

记录下vue3.0的坑——看同一个新旧数据

时间:2023-03-27 10:36:42 JavaScript

1。首先上传代码用户名:空,});//constrouter=useRouter();//constgoto_home=(()=>{//router.replace('/userList')//})constaffirm=()=>{console.log('enter')}watch(()=>state.username,(newValue,oldValue)=>{//直接监听console.log("Changed",newValue,oldValue,state);});return{确认,...toRefs(state)};},};这是监控的正确方式2.如果是监控所有watch(state,(newValue,oldValue)=>{//直接监控console.log("countchanged",newValue,旧值,状态);});newValue和oldValue是一样的(都是修改后的值)推荐方法一,这样可以监控修改前后的值