weex的元素定位fixed类型,bottom为0时,ios实际不为0

在weex实践tabbar的时候,tabbar是通过position:fixed来定位的。代码如下:

  .tabbar {
    flex-direction: row;
    position: absolute;
    width: 750;
    height: 88;
    left: 0;
    right: 0;
    bottom:0;
  }

执行这段代码以后,在ios设备上,实际上他并不显示在bottom为0的位置 。
请看截图,请问如何解决。
图片描述

在最高层级的div加了style,全部代码如下:

<template>
  <div style="background-color:red;position:absolute;top:0;bottom:0;left:0;right:0;">
    <tabnav></tabnav>
  </div>
</template>

<style>

</style>

<script>
  export default {
    data: {
    },
    methods: {
    },
    components:{
      tabnav: require("./components/tabbar.vue")
    }
  }
</script>

执行结果如下:
图片描述

阅读 6.3k
4 个回答

可以给最外层的容器设置背景颜色,查看是否容器整体的高度就是到那里。

如果不能确定问题,就去使用debug模式,在浏览器中查看一个dom结构,以及dom的大小,这样比较容易找清楚问题

  • (void)viewDidLayoutSubviews
    {

    _weexHeight = self.view.frame.size.height;

    }

修改下 native 容器的高度

修复方法

platforms/ios/WeexDemo/WeexScanner/WXDemoViewController.m

_weexHeight = self.view.frame.size.height - 64;
修改为
_weexHeight = self.view.frame.size.height - 20;

_instance.frame = CGRectMake(self.view.frame.size.width-width, 0, width, _weexHeight);
修改为
_instance.frame = CGRectMake(self.view.frame.size.width-width, 20, width, _weexHeight);

参考 weex iOS app 编译之后 tabbar 没有贴着底部

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进