ant-design-vue/components/_util/hooks/_vueuse/useSupported.ts
2023-04-05 22:03:02 +08:00

14 lines
332 B
TypeScript

import { tryOnMounted } from './tryOnMounted';
import { shallowRef } from 'vue';
export function useSupported(callback: () => unknown, sync = false) {
const isSupported = shallowRef<boolean>();
const update = () => (isSupported.value = Boolean(callback()));
update();
tryOnMounted(update, sync);
return isSupported;
}