1***@qq.com
1***@qq.com
  • 发布:2020-03-15 12:20
  • 更新:2023-03-21 20:07
  • 阅读:12415

【建议】uniapp建议设置最大宽度

分类:uni-app

现在在pc打开uniapp的\h5,因为屏幕太大了,体验不好

2 关注 分享
2***@qq.com j***@126.com

要回复文章请先登录注册

zhanghao

zhanghao

代码重写贴下,排版出问题了
···
var timer_id = 0;

if(typeof window !='undefined')
if (window.innerWidth>750){
window.innerWidth=750;
timer_id = setInterval(function(){
//适配尺寸
var el = document.querySelector('html');
var n = Number(el.style.fontSize.replace('px',''));
if(n>30){
el.style.fontSize='30px';
clearInterval(timer_id);
}

console.log(el.style.fontSize);
},100);
}

···
2020-07-18 17:44
zhanghao

zhanghao

又想到个办法,有点小bug,只能改h5的。可以去研究下,在app.vue内<script>下第一行,贴上下面代码
·
var timer_id = 0;

if(typeof window !='undefined')
if (window.innerWidth>750){
window.innerWidth=750;
timer_id = setInterval(function(){
//适配尺寸
var el = document.querySelector('html');
var n = Number(el.style.fontSize.replace('px',''));
if(n>30){
el.style.fontSize='30px';
clearInterval(timer_id);
}

console.log(el.style.fontSize);
},100);
}
·
2020-07-18 17:43
zhanghao

zhanghao

点发行打包后,建个新的html静态页面,body里面就放一个iframe元素,指向index.html 然后给他设置下样式。如下面的代码,就可以实现电脑最大宽度750px了。
·
<html>
<head>
<title></title>
<style>
iframe{
display:block;
width:100%;
max-width:750px;
margin:0 auto;
border:none;
height:100%;
}
</style>
</head>
<body>
<iframe src="index.html" scrolling="no"></iframe>
</body>
</html>
·
2020-07-18 16:10
6***@qq.com

6***@qq.com

回复 zzzzzfreea :
这个应该就是大家想要的效果,不知道如何实现的
2020-06-03 09:28
2***@qq.com

2***@qq.com

同建议,现在想在popup里用list,结果给uni-list和uni-list-item设置宽带都不生效
2020-05-15 09:28
zzzzzfreea

zzzzzfreea

https://m.qinxuan.honor.cn/
2020-04-11 11:17
zzzzzfreea

zzzzzfreea

可以参考下这个案例,具体实现就不知道了https://m.qinxuan.honor.cn/
2020-04-11 11:16