isProxy">isProxyisReactive">isReactiveisReadonly">isReadonlyisProxy检查对象是否是由 reactive 或 readonly 创建的 proxy。 isReactive检查对象是否是由 reactive 创建的响应式代理 如果该代理是 readonly 创建的,但包裹了由 reactive 创建的另一个代理,它也会返回 true isReadonly检查对象是否是由 readonly 创建的只读代理 <script setup> import { isProxy, isReactive, isReadonly, reactive, readonly, ref, shallowReadonly, shallowReactive } from‘@vue/reactivity’ const count = ref(0) const dataList = reactive({ name:‘吴八哥’, age:18 }) const dataList2 = shallowReactive({ name:‘rose’ }) const testData = readonly({ title:‘测试数据’ }) const testData2 = shallowReadonly({ title:‘测试数据2’ }) // - isReactive /* console.log(isReactive(dataList)) // true console.log(isReactive(count.value)) // false console.log(isReactive(count)) // false console.log(isReactive(testData)) // false */ // - isReadonly /* console.log(isReadonly(testData)) // true console.log(isReadonly(testData2)) // true console.log(isReadonly(dataList)) // false console.log(isReadonly(count)) // false */ // - isProxy /* console.log(isProxy(dataList)) // true console.log(isProxy(dataList2)) // true console.log(isProxy(testData)) // true console.log(isProxy(testData2)) // true console.log(isProxy(count)) console.log(isProxy(count.value)) */ console.log(dataList) console.log(count) </script> <template> </template> <style> </style>