mounted() {
// 监听页面的窗口的变化,每次窗口变化调用等比例缩放方法
window.addEventListener("resize", this.bodyScale, false);
},
methods: {
// 页面等比例缩放的方法
bodyScale() {
var deviceWidth = document.documentElement.clientWidth; //获取当前分辨率下的可是区域宽度
var scale = deviceWidth / 1920; // 分母——设计稿的尺寸
document.documentElement.style.zoom = scale; //放大缩小相应倍数
},
}
文章来源: