mirror of
https://gitee.com/ant-design-vue/ant-design-vue.git
synced 2024-12-16 01:41:15 +08:00
22 lines
492 B
TypeScript
22 lines
492 B
TypeScript
|
import { onMounted, onUnmounted, Ref, ref } from 'vue';
|
||
|
import ResponsiveObserve, { ScreenMap } 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;
|