资讯中心

资讯中心

当前位置:主页 > 资讯中心 > 常见问题 >

利用screenWidth与screenHeight手算布局

发布时间:作者:济南小程序开发来源:未知点击:

一:利用screenWidth与screenHeight手算布局

在app.js中获取到设备宽高


  1. // 设备信息
  2. wx.getSystemInfo({
  3. success: function(res) {
  4. that.screenWidth = res.windowWidth;
  5. that.screenHeight = res.windowHeight;
  6. that.pixelRatio = res.pixelRatio;
  7. }
  8. });

然后挖坑在布局页面


  1. <view class="sidebar" style="height: {{sidebarHeight}}px;">
  2. <dt>
  3. <image src="{{item.avatar.attributes.url}}" mode="scaleToFit" bindtap="avatarTap" data-object-id="{{item.objectId}}" style="width:{{imageWidth}}px; height: {{imageWidth}}px;"/>
  4. </dt>

最后在js中实现数值


  1. setImageWidth: function () {
  2. var screenWidth = getApp().screenWidth;
  3. var imageWidth = (screenWidth - 130) / 3;
  4. this.setData({
  5. imageWidth: imageWidth
  6. });
  7. },
  8. setSideHeight: function () {
  9. this.setData({
  10. sidebarHeight: getApp().screenHeight
  11. });
  12. },

如图:

二:tomcat http 转 https


由于小程序需要使用https协议,在使用用腾讯云的服务器时,负载均衡服务器(SSL证书部署在此服务器上)与业务服务器上的apache之间使用的是http,apache与tomcat之间也使用的是http,这样导致两个问题,tomcat 在redirect的时会跳转到http://127.0.0.1上

解决方案:
1.在tomcat,service.xml中Connector 增加proxyName,proxyPort-->解决跳转到127.0.0.1的问题

TOP

QQ客服

15069066861

拨打电话