isProxy
::检查一个对象是否是由 reactive
或者 readonly
方法创建的代理。
实例:
<template>
<p>The refNum is:{{ refNum}}</p>
<p>Is the refNum isProxy:{{ isProRes1 }}</p>
<p>The readNum is:{{ readNum}}</p>
<p>Is the readNum isProxy:{{ isProRes2 }}</p>
<p>The count.num is:{{ count.num}}</p>
<p>Is the count isProxy:{{ isProRes3 }}</p>
</template>
<script lang="ts">
import { ref, reactive, readonly, isProxy } from 'vue'
export default {
setup() {
const refNum = ref(3)
const readNum = readonly(refNum)
const count = reactive({
num: 5,
})
const isProRes1 = isProxy(refNum)
const isProRes2 = isProxy(readNum)
const isProRes3 = isProxy(count)
return {
refNum,
readNum,
count,
isProRes1,
isProRes2,
isProRes3,
}
},
}
</script>
页面效果: