1 Star 0 Fork 235

why涛/blog

forked from openGauss/blog 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
useWindowResize.ts 840 Bytes
一键复制 编辑 原始数据 按行查看 历史
pxq 提交于 2023-11-17 11:47 +08:00 . fix: 为优化ci、同步官网项目结构
import { onMounted, onUnmounted, ref } from 'vue';
import { isBrowser } from '@/shared/utils';
const useWindowResize = () => {
let width = Infinity;
if (isBrowser()) {
width =
window.innerWidth ||
document.documentElement.clientWidth ||
document.body.clientWidth;
}
const screenWidth = ref(width);
const onResize = () => {
screenWidth.value =
window.innerWidth ||
document.documentElement.clientWidth ||
document.body.clientWidth;
};
onMounted(() => {
screenWidth.value =
window.innerWidth ||
document.documentElement.clientWidth ||
document.body.clientWidth;
window.addEventListener('resize', onResize);
});
onUnmounted(() => {
window.removeEventListener('resize', onResize);
});
return screenWidth;
};
export default useWindowResize;
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/whytao/blog.git
git@gitee.com:whytao/blog.git
whytao
blog
blog
b72d3a0f7c5fca796e35a8261a71d508248a2df1

搜索帮助