跳到主要內容

useSupported

類別
導出大小
176 B
最後變更
2 週前

SSR 相容性 isSupported

用法

ts
import { useSupported } from '@vueuse/core'

const isSupported = useSupported(() => navigator && 'getBattery' in navigator)

if (isSupported.value) {
  // do something
  navigator.getBattery
}

類型宣告

typescript
export declare function useSupported(
  callback: () => unknown,
): ComputedRef<boolean>
export type UseSupportedReturn = ReturnType<typeof useSupported>

原始碼

SourceDocs

貢獻者

Robin
Anthony Fu
Anthony Fu
Fernando Fernández
Jelf

變更日誌

v12.8.0 於 2025/3/5
9afee - feat(useCached): 新增 options.deepRefs (#4591)
v12.0.0-beta.1 於 2024/11/21
0a9ed - feat!: 移除 Vue 2 支援,優化 bundles 並清理程式碼 (#4349)
v10.0.0-beta.2 於 2023/3/28
55a32 - feat: 支援追蹤回呼函式的響應性 (#2904)

根據 MIT 許可證發布。