Skip to content

createRef

根据 deep 参数返回 deepRefshallowRef

¥Returns a deepRef or shallowRef depending on the deep param.

用法

¥Usage

ts
import { createRef } from '@vueuse/core'
import { isShallow, ref } from 'vue'

const initialData = 1

const shallowData = createRef(initialData)
const deepData = createRef(initialData, true)

isShallow(shallowData) // true
isShallow(deepData) // false
js
import { createRef } from '@vueuse/core'
import { isShallow } from 'vue'
const initialData = 1
const shallowData = createRef(initialData)
const deepData = createRef(initialData, true)
isShallow(shallowData) // true
isShallow(deepData) // false