手机适配问题?

小程序 文章 2021-01-28 09:21 363 0 全屏看文

AI助手支持GPT4.0

手机适配问题?Phone adaptation problem?

手机适配问题?

在wxss样式文件中,对组件的高使用了rpx单位,开发基准按照iphone6编写,但是如果有的手机高度小于iphone6,则自动上下滑动,怎么在wxss中根据js文件中获取到的手机基本信息中的宽高适配。。。。

In wxss style file, rpx unit is used for the height of components, and the development benchmark is written according to iPhone 6. However, if some mobile phones are smaller than iPhone 6, they will slide up and down automatically. How to adapt the width and height in wxss according to the basic information of mobile phones obtained from JS file....

回答:

brave:

或许你用vh也可以实现想要的布局?

belief:这个我不知道,没接触过
陈宇明:

不能直接改wxss的样式。通常是在js中直接通过setData的方法动态设置wxml布局中的style进行样式上的修改。

belief:.text{
      height:var(hh);

}


wxml文件中:



js文件中:
data{
    varHeight:100
}
belief:这样行不行
小黎:

wx.getSystemInfo()这个可以获取到系统信息,包括手机型号,屏幕可使用宽高


belief:这个我拿到了,然后怎么办,wxss中有大量的height、margin、padding等,怎么适配其他手机

-EOF-

AI助手支持GPT4.0