问题描述
最近做的项目中,需要对react后台管理系统进行比例缩放,找了很多资料最终功夫不负有心人,解决了这个问题,记录一下
解决方案:
我的项目是umi创建的,src > pages > document.ejs 具体在哪修改看自己的实际情况
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="keywords" content="" />
<meta name="description" content="" />
// user-scalable=yes 这个是最重要的 width设置移动端转到PC端的长度
<meta name="viewport" content="user-scalable=yes, width=1920, minimum-scale=0.1" />
<title>后台管理系统</title>
</head>
<body>
<script>
// 旋转之后要重新绑定,避免适配失败
window.addEventListener("orientationchange", function() {
let i = document.getElementsByTagName('meta');
i[4]["content"] = "user-scalable=yes, width=1920, minimum-scale=0.1";
}, false);
</script>
</body>
</html>