Skip to content

useSupported ​

Category
Export Size
176 B
Last Changed
4 months ago

SSR 兼容性检测 isSupported

用法 ​

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

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

if (isSupported.value) {
  // 执行一些操作
  navigator.getBattery
}

Type Declarations ​

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

Source ​

Source • Docs

Contributors ​

丶远方
Robin
Anthony Fu
Anthony Fu
Fernando Fernández
Jelf

Changelog ​

9afee - feat(useCached): add options.deepRefs (#4591)
0a9ed - feat!: drop Vue 2 support, optimize bundles and clean up (#4349)

Released under the MIT License.