<script setup lang="ts">
import { isProxy, isReactive, isRef, markRaw, reactive, ref, toRaw } from 'vue';
const obj = { name: "张三" }
const objRef = ref(obj)
const objReact = reactive(obj)
/* isRef */
console.log(isRef(obj)) //false
console.log(isRef(objRef)) //true
console.log(isRef(objReact)) //false
/* isReactive */
console.log(isReactive(obj)) //false
console.log(isReactive(objRef)) //false
console.log(isReactive(objReact)) //true
/* isProxy */
console.log(isProxy(obj)) //false
console.log(isProxy(objRef)) //true
console.log(isProxy(objReact)) //true
/* isReactive */
console.log(isReactive(obj)) //false
console.log(isReactive(objRef)) //false
console.log(isReactive(objReact)) //true
/* toRaw 返回一个响应式对象的原始普通对象 */
console.log(toRaw(objRef.value)) //{ name: "张三" }
console.log(toRaw(objReact)) //{ name: "张三" }
</script>
Vue3学习记录——(9) isRef、isReactive、isProxy、toRaw
最新推荐文章于 2024-08-21 11:02:00 发布