map组件高度问题
发布于 5 年前 作者 yang47 7792 次浏览 来自 问答

<map class='map-container' style='width:100%;height:{{windowHeight}}px;'></map>

js代码如下:

Page({
   
  data: {
    windowHeight: 0,
  },
 
  onLoad: function (options) {
    let systemInfo = wx.getSystemInfoSync();
    this.setData({
      windowHeight: systemInfo.windowHeight
    });
  },
 
})

iOS中展示效果如下:

地图高度为0, 请问如何解决呀

3 回复

不知道css中calc的兼容性如何, 我的map高度不是占满全屏的。在js中设置map高度的话,Android正常, iOS中有很多几率出现上面截图的情况

在初始化前给一个class position:absoulte top:-10rpx opcaity:0就可以了

没有复现你的这个问题,如果你想要map占满整个屏幕的话,可以将 width设置成750rpx, height 设置成100vh;

回到顶部