方案:设置动态style => 监听窗口变化 => 赋值。废话少说上代码
<template> 里给容器绑定style动态设置
引入onMounted 、ref
import {onMounted, ref } from 'vue'
写方法
const scaleva = ref()
const bodyScale = () => {
const devicewidth = document.documentElement.clientWidth
const scale = devicewidth /1920
scaleva.value = scale
}
onMounted(() => {
bodyScale()
window.onresize = () => {
return (() => {
bodyScale()
})()
}
})
OK
网友评论