CSS用px
<view class="" :style="pageStyle">
<view>渲染的内容</view>
</view>
computed: {
pageStyle() {
return {
transform: `scale(${this.scale})`,
'transform-origin': '0px 0px'
}
}
},
data() {
return {
scale: 1
};
},
created() {
this.autoSize()
window.onresize = () => {
this.autoSize()
}
},
methods: {
// 自适应屏幕宽度按比例缩放页面
autoSize() {
// 获取网页宽度
let width = window.innerWidth
// 计算缩放比例
this.scale = width / 1920;
}
}