vue3 全局监听浏览器窗口变化,刷新当前页面布局
添加文件
App.vue
代码
<template>
<!-- element-plus汉化处理 -->
<el-config-provider :locale="zhCn">
<router-view v-if="render"/>
</el-config-provider>
</template>
<script setup>
import { ElConfigProvider } from 'element-plus'
import zhCn from 'element-plus/lib/locale/lang/zh-cn'
import { ref, onMounted, nextTick } from 'vue'
let render = ref(true)
onMounted(()=>{
window.addEventListener('resize', reload)
})
const reload = () => {
render.value = false;
nextTick(()=>{
render.value = true;
})
}
</script>