mirror of
https://gitee.com/ant-design-vue/ant-design-vue.git
synced 2024-12-15 09:21:25 +08:00
24 lines
568 B
TypeScript
24 lines
568 B
TypeScript
import type { Ref } from 'vue';
|
|
import { onMounted, onUnmounted, ref } from 'vue';
|
|
import type { ScreenMap } from '../../_util/responsiveObserve';
|
|
import ResponsiveObserve from '../../_util/responsiveObserve';
|
|
|
|
function useBreakpoint(): Ref<ScreenMap> {
|
|
const screens = ref<ScreenMap>({});
|
|
let token = null;
|
|
|
|
onMounted(() => {
|
|
token = ResponsiveObserve.subscribe(supportScreens => {
|
|
screens.value = supportScreens;
|
|
});
|
|
});
|
|
|
|
onUnmounted(() => {
|
|
ResponsiveObserve.unsubscribe(token);
|
|
});
|
|
|
|
return screens;
|
|
}
|
|
|
|
export default useBreakpoint;
|