V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
Yukee798

请教一下关于微信小程序动态适配不同机型的方案

  •  
  •   Yukee798 · Mar 29, 2021 · 1966 views
    This topic created in 1855 days ago, the information mentioned may be changed or developed.

    最近在学习 Taro 开发微信小程序,遇到了一个问题就是给一个顶部的 NavBar 设置成了 fixed,然后这个 NavBar 会覆盖下面的内容,为了不让它覆盖,则在其后面加了一个 空的块元素 ,高度设置为 NavBar 的高度即可,但是不同的机型下,NavBar 的高度又不同,那么这个 空的块元素 就需要根据 NavBar 的高度动态变化,有什么 API 可以实现这个需求吗,找了半天文档也没找到,另外请教一下前辈们有其他更好的解决方案吗?

    5 replies    2021-03-29 18:19:56 +08:00
    DFshpAq3
        1
    DFshpAq3  
       Mar 29, 2021
    DFshpAq3
        2
    DFshpAq3  
       Mar 29, 2021
    @DFshpAq3 statusBarHeight
    Yukee798
        3
    Yukee798  
    OP
       Mar 29, 2021
    @DFshpAq3 感谢!但是 NavBar 是我自定义的组件,它的高度随着不同机型而改变,有什么办法可以拿到它的高度吗。
    a1248499257
        4
    a1248499257  
       Mar 29, 2021
    @Yukee798 拿到了 `statusBarHeight ` 不就可以根据不同机型的高度变了嘛..?
    hengstchon
        5
    hengstchon  
       Mar 29, 2021 via Android
    @Yukee798 自己定义的组件为啥会拿不到高度?
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1058 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 35ms · UTC 18:53 · PVG 02:53 · LAX 11:53 · JFK 14:53
    ♥ Do have faith in what you're doing.