在组件中使用uni.createSelectorQuery(),Android手机可获取到组件元素高度。iPhone手机获取组件元素高度为0;
<u-parse id="sunui-grand-summary-id" :content="content" @preview="preview" @navigate="navigate" />
onReady() {
let that = this
that.$nextTick(() => {
setTimeout(res => {
uni.createSelectorQuery().in(that).selectAll("#sunui-grand-summary-id")
.boundingClientRect(
resp => {
console.log(resp, '文本高度22');
if (resp[0].height >= 64) {
that.showBtn = true
} else {
that.showBtn = false
}
}).exec();
}, 0)
})
},
1 个回复
DCloud_UNI_GSQ
APP 还是小程序?
注意时机,延迟是否准确,是否 u-parse 已经解析完毕