①找到vue的主入口HTML文件然后加上:
<script>
window.onload = function() {
var deviceWidth = document.documentElement.clientWidth ||document.body.clientWidth;
if (deviceWidth > 750) {
deviceWidth = 750;
}
document.documentElement.style.fontSize = (deviceWidth / 750) * 100 + "px";
};
window.onresize = function() {
var deviceWidth =
document.documentElement.clientWidth || document.body.clientWidth;
if (deviceWidth > 750) {
deviceWidth = 750;
} document.documentElement.style.fontSize = (deviceWidth / 750) * 100 + "px";
};
</script>
这样可以在组件中的样式中使用rem来进行屏幕的缩放了