isDefined

isDefined

Refのための非nullishチェック型ガード。

使用法

import { isDefined } from '@vueuse/core'

const example = ref(Math.random() ? 'example' : undefined) // Ref<string | undefined>

if (isDefined(example))
  example // Ref<string>