在使用bindPopup时,发现在屏幕中间位置使用targetSpace距离正常,但是屏幕两侧时targetSpace展示距离太大,导致UI展示异常。代码如下:
.bindPopup(this.handlePopup, {
// CustomPopupOptions类型气泡的内容
builder: this.popupBuilder,
placement: Placement.Top,
targetSpace: -10,
enableArrow: true, // 气泡弹出时不显示箭头
popupColor: "#333333",
backgroundBlurStyle: BlurStyle.NONE, // 关闭气泡的模糊背景
showInSubWindow:true,
arrowWidth:10,
arrowHeight:4,
气泡太靠近边缘的时候会发生避让,最后导致targetSpace不生效,这种是系统规格现象,建议使用offset来规避,参考文档:https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/ts-universal-attributes-location-V5\#offset