vue 2.0 及 vue 3.0 rem配置
vue 2.0 配置 rem
首先先安装postcss-px2rem (百度可以) https://www.jianshu.com/p/e6476bbc2131
npm install postcss-px2rem
找到文件 build / vue-loader.config.js 添加
const px2rem = require(‘postcss-px2rem‘) postcss: function() { return [px2rem({remUnit: 75})]; }
在index.html 文件中配置
<script> document.getElementsByTagName(‘html‘)[0].style.fontSize = (document.documentElement.clientWidth || document.body .clientWidth) / 10 + ‘px‘; window.addEventListener("resize", () => { document.getElementsByTagName(‘html‘)[0].style.fontSize = (document.documentElement.clientWidth || document .body.clientWidth) / 10 + ‘px‘; }); </script>
vue 3.0 配置 rem (百度可以)
相关推荐
JKjiang 2020-07-30
葉無聞 2020-06-06
发条戏子 2020-05-30
hxmilyy 2020-05-11
csm0 2020-03-05
haolt00 2020-02-23
nicepainkiller 2020-01-01
Enjoyendless 2020-01-11
赵家小少爷 2019-12-25
87354091 2019-12-23
oKeYue 2019-11-20
zuncle 2019-11-18
csdnuuu 2019-11-05
tomli 2019-11-04
CaiKanXP 2019-11-02
绿豆饼 2019-10-20
qianxiaona 2014-06-29
wangnantjobj 2015-08-28