Vue3学习记录——(9) isRef、isReactive、isProxy、toRaw

<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学习记录,学习,javascript,vue.js)