小程序中想要使用windowHeight需要在当前元素中添加style='height:"{{windowHeight}}"px;'
但不同情况下使用三元表达式改变高度时写成
<scroll-view scroll-y style='{{isHaveVideo ? "height:{{haveVideoHeight}}px" : "height:{{windowHeight}}px"}}'></scroll-view>
代码读到{{isHaveVideo ? “height:{{haveVideoHeight}}就会停止,所以更改为
<scroll-view scroll-y style='{{"height: " + (isHaveVideo ? haveVideoHeight : windowHeight) + "px;"}}'></scroll-view>
数据绑定的{{ }}只需要写在最外面即可
关于获取屏幕高度的方法可以看我的另一篇文章哦