- 2024-07-03vue3 toref ref toRow unref等等使用和功能测试
代码测试js代码constrowData=reactive({nameAbc:'sdfsdf'})console.log(rowData,"rowData")letrowDataValue=toRaw(rowData);console.log(rowDataValue,"rowdatavalue")//toRefs使对象本身转为普通对象,但是子属性全部转为refvalue方式//toRef
- 2023-02-07vue3 | isRef、unref、toRef、toRefs
isRef检查某个值是否是ref。是返回true,否则返回false。constnum=ref(10);constnum1=20;constnum2=reactive({data:30});console.log(isRef(num));//tru
- 2023-01-29unref、isref、toRef、toRefs
unref()如果参数是一个ref则返回它的value,否则返回参数本身unref(val)相当于val=isRef(val)?val.value:valfunctioninitialCount(value:number|Ref<number>){
- 2022-09-22Vue3:响应式 API-工具函数 isRef()、unref()、toRef()、toRefs()、readonly()
isRef()检查某个值是否为ref。<scriptsetup>import{ref,isRef}from"vue"letmsg=ref(0)functionfn(){console.log(isRef(msg))//判断是否为响应性变量