@Entry
@Component
struct HoverPopup1 {
str: string = 'Tips:自定义提示';
build() {
Row() {
Text('表头名')
.fontSize(30);
Image($r('app.media.startIcon'))
.width(30)
.bindTips(this.str, {
// 设置悬浮气泡的显示时延
appearingTime: 10,
// 设置悬浮气泡的隐藏时延
disappearingTime: 300,
appearingTimeWithContinuousOperation: 300,
disappearingTimeWithContinuousOperation: 0,
// 设置是否显示气泡箭头。值为true时,显示箭头;值为false时,不显示箭头
enableArrow: true,
});
}
.justifyContent(FlexAlign.Center)
.height('100%')
.width('100%');
}
} 效果预览:

@Entry
@Component
struct HoverPopup2 {
str: string = 'Tips:自定义提示';
@State handlePopup: boolean = false;
build() {
Row() {
Text('表头名')
.fontSize(30);
Image($r('app.media.startIcon'))
.width(30)
.onHover((isHover: boolean, event: HoverEvent) => {
console.info(`${event}`);
if (isHover) {
// 鼠标悬浮
this.handlePopup = true;
}
})
.bindPopup($$this.handlePopup, {
message: this.str,
autoCancel: true,
enableArrow: true,
onStateChange: (e) => {
if (!e.isVisible) {
this.handlePopup = false;
}
}
});
}
.justifyContent(FlexAlign.Center)
.height('100%')
.width('100%');
}
} 效果预览:
