1
This commit is contained in:
18
src/utils/on-size-change.ts
Normal file
18
src/utils/on-size-change.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
/**
|
||||
* 监听屏幕尺寸改变封装
|
||||
*/
|
||||
import { watch } from 'vue';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { useThemeStore } from '@/store/modules/theme';
|
||||
|
||||
export function onSizeChange(hook: Function) {
|
||||
if (!hook) {
|
||||
return;
|
||||
}
|
||||
const themeStore = useThemeStore();
|
||||
const { contentWidth } = storeToRefs(themeStore);
|
||||
|
||||
watch(contentWidth, () => {
|
||||
hook();
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user