选择单位rem,根据屏幕大小的不同,动态赋予根元素的font-size值,来调整页面显示问题
data(){
return{
show:false,
screenWidth: document.body.clientWidth, // 屏幕尺寸
}
},
// 钩子函数
mounted () {
const that = this
window.onresize = () => {
return (() => {
window.screenWidth = document.body.clientWidth
that.screenWidth = window.screenWidth
})()
}
var new = document.documentElement;
new.style.fontSize = that.screenWidth / 96 + 'px'
console.log(that.screenWidth)
console.log(d.style.fontSize )
},