isRef
:检查一个对象是否为 ref
包装过的对象。
实例:
<template>
<p>The count.num is:{{ count.num}}</p>
<p>Is the count isRef:{{ isResult }}</p>
<p>The val is:{{ val}}</p>
<p>Is the val isRef:{{ isRes }}</p>
</template>
<script lang="ts">
import { ref, reactive, isRef } from 'vue'
export default {
setup() {
const val = ref(3)
const count = reactive({
num: 5,
})
const isRes = isRef(val)
const isResult = isRef(count)
return {
val,
count,
isRes,
isResult,
}
},
}
</script>
页面效果: