Skip to content

Commit

Permalink
fix: 兼容实际屏幕宽度值为小数的情况
Browse files Browse the repository at this point in the history
  • Loading branch information
guoenxuan committed Apr 3, 2024
1 parent 0b91df9 commit 5543fba
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export class H5WebpackPlugin {
const rootValue = baseFontSize / options.deviceRatio![designWidth!] * 2
let htmlScript = ''
if ((options?.targetUnit ?? 'rem') === 'rem') {
htmlScript = `!function(n){function f(){var e=n.document.documentElement,w=e.getBoundingClientRect().width,x=${rootValue}*w/${designWidth};e.style.fontSize=x>=${max}?"${max}px":x<=${min}?"${min}px":x+"px"}n.addEventListener("resize",(function(){f()})),f()}(window);`
htmlScript = `!function(n){function f(){var e=n.document.documentElement,w=Math.floor(e.getBoundingClientRect().width),x=${rootValue}*w/${designWidth};e.style.fontSize=x>=${max}?"${max}px":x<=${min}?"${min}px":x+"px"}n.addEventListener("resize",(function(){f()})),f()}(window);`
}
const args: Record<string, string | string []> = {
filename: `${entry || 'index'}.html`,
Expand Down

0 comments on commit 5543fba

Please sign in to comment.