Skip to content

isDefined

类别
导出大小
103 B
最近修改
2 days ago

Ref 的非无效检查类型保护。

🌐 Non-nullish checking type guard for Ref.

用法

🌐 Usage

ts
import { 
isDefined
} from '@vueuse/core'
const
example
=
ref
(
Math
.
random
() ? 'example' :
undefined
) // Ref<string | undefined>
if (
isDefined
(
example
))
example
// Ref<string>