Mobile project, you need to set how many pixels the 1rem is through js, but the document.documentElement.clientWidth that the device width document.documentElement.clientWidth gets in the Mobile QQ chat dialog box is occasionally 0. There will be no problem in the real QQ Browser. I don"t know what the browser in Mobile QQ"s chat dialog is.
If you changeto document.body.clientWidth, you will occasionally get 0
.<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no">
<title>Document</title>
</head>
<body>
<script>
window.onload=function () {
var remSize = document.documentElement.clientWidth
}
</script>
</body>
</html>