企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
>[danger] ##### isProxy 检查对象是否是由 [`reactive()`](https://cn.vuejs.org/api/reactivity-core.html#reactive)、[`readonly()`](https://cn.vuejs.org/api/reactivity-core.html#readonly)、[`shallowReactive()`](https://cn.vuejs.org/api/reactivity-advanced.html#shallowreactive)或[`shallowReadonly()`](https://cn.vuejs.org/api/reactivity-advanced.html#shallowreadonly)创建的 proxy。 ~~~ export default { name: 'App', setup() { const info = { name: 'w' } const proxyInfo = new Proxy(info, {}) const refInfo = ref(info) const reactiveInfo = reactive(info) const readonlyInfo = readonly(info) const isP = isProxy(info) // false const isP1 = isProxy(refInfo) // false const isP2 = isProxy(reactiveInfo) // true const isP3 = isProxy(readonlyInfo) // true const isP4 = isProxy(proxyInfo) // false console.log(isP, isP1, isP2, isP3, isP4) // false false true true false return {} }, } ~~~ >[danger] ##### isReactive 1. [`reactive()`](https://cn.vuejs.org/api/reactivity-core.html#reactive)或[`shallowReactive()`](https://cn.vuejs.org/api/reactivity-advanced.html#shallowreactive)创建的代理。除了是纯`isReactive `对象外如果该代理是 `readonly `创建的,但包裹了由 `reactive `创建的另一个代理,它也会返回 `true` ~~~ import { reactive, isReactive } from 'vue' export default { setup() { const state = reactive({ name: 'John' }) console.log(isReactive(state)) // -> true } } ~~~ >[danger] ##### isReadonly 1. 检查对象是否是由 `readonly `创建的只读代理。 >[danger] ##### isRef 1. 判断值是否是一个ref对象 ~~~ let foo: unknown if (isRef(foo)) { // foo 的类型被收窄为了 Ref<unknown> foo.value } ~~~