Commit 63866784 authored by 高宇's avatar 高宇

2024/01/24 需求变更

parent 75420fef
// rem等比适配配置文件
// 基准大小 // 基准大小
const baseSize = 16 const baseSize = 16
// 设置 rem 函数 // 设置 rem 函数
function setRem() { function setRem() {
// 当前页面屏幕分辨率相对于 1920宽的缩放比例,可根据自己需要修改 // 当前页面宽度相对于 1920 宽的缩放比例,可根据自己需要修改。
const scale = document.documentElement.clientWidth / 1920 const scale = document.documentElement.clientWidth / 1920
// 设置页面根节点字体大小, 字体大小最小为12
// 设置页面根节点字体大小(“Math.min(scale, 2)” 指最高放大比例为2,可根据实际业务需求调整) // 设置页面根节点字体大小(“Math.min(scale, 2)” 指最高放大比例为2,可根据实际业务需求调整)
document.documentElement.style.fontSize = baseSize * Math.min(scale, 2) + 'px' document.documentElement.style.fontSize = baseSize * Math.min(scale, 2) + 'px'
} }
// 初始化 // 初始化
setRem() setRem()
// 改变窗口大小时重新设置 rem // 改变窗口大小时重新设置 rem,这里最好加上节流
window.onresize = function() { window.onresize = function() {
setRem() setRem()
} }
...@@ -56,12 +56,7 @@ module.exports = { ...@@ -56,12 +56,7 @@ module.exports = {
loaderOptions: { loaderOptions: {
postcss: { postcss: {
plugins: [ plugins: [
postcss, postcss
require('postcss-pxtorem')({
rootValue: 16, // 换算的基数
selectorBlackList: [], // 忽略转换正则匹配项 列入一些ui库, ['.el'] 就是忽略elementUI库
propList: ['*']
})
] ]
}, },
sass: { sass: {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment