HarmonyOS LazyForEach的ListItem划出屏幕没有调用onDisAppear这个是正常的吗

build() {
  Row() {
    List({ space: commonConst.LIST_ITEM_SPACE }) {
      LazyForEach(this.goodsListData, (item: GoodsListItemType) => {
        ListItem() {
          Row() {
            Column() {
              Image(item?.goodsImg)
                .width(commonConst.LAYOUT_WIDTH_OR_HEIGHT)
                .height(commonConst.LAYOUT_WIDTH_OR_HEIGHT)
            }
            .width(commonConst.GOODS_IMAGE_WIDTH)
            .height(commonConst.LAYOUT_WIDTH_OR_HEIGHT)

            Column() {
              Text(item?.goodsName)
                .fontSize(commonConst.NORMAL_FONT_SIZE)
                .margin({ bottom: commonConst.BIGGER_FONT_SIZE })
              Text(item?.advertisingLanguage)
                .fontColor($r('app.color.gray'))
                .fontSize(commonConst.GOODS_EVALUATE_FONT_SIZE)
                .margin({ right: commonConst.MARGIN_RIGHT, bottom: commonConst.BIGGER_FONT_SIZE })
              Row() {
                Text(item?.evaluate)
                  .fontSize(commonConst.GOODS_EVALUATE_FONT_SIZE)
                  .fontColor($r('app.color.deepGray'))
                Text(item?.price).fontSize(commonConst.NORMAL_FONT_SIZE).fontColor($r('app.color.freshRed'))
              }
              .justifyContent(FlexAlign.SpaceAround)
              .width(commonConst.GOODS_LIST_WIDTH)
            }
            .padding(commonConst.GOODS_LIST_PADDING)
            .width(commonConst.GOODS_FONT_WIDTH)
            .height(commonConst.LAYOUT_WIDTH_OR_HEIGHT)
          }
          .justifyContent(FlexAlign.SpaceBetween)
          .height(commonConst.GOODS_LIST_HEIGHT)
          .width(commonConst.LAYOUT_WIDTH_OR_HEIGHT)
        }.onAppear(() => {
          console.log("lzqnet  dddd")
        }).onDisAppear(() => {
          console.log("lzqnet   eeeee")
        })

在item里实现了下面代码,但是item滑出屏幕后,onDisAppear没有被调用,这是什么情况呢

onAppear(() => {
  console.log("lzqnet  dddd")
}).onDisAppear(() => {
  console.log("lzqnet   eeeee")
})
HarmonyOS
2024-12-18 15:49:03
浏览
收藏 0
回答 1
待解决
回答 1
按赞同
/
按时间
aquaa

onDisaAppear是组件从组件树卸载消失时触发,组件不可见可以在onVisibleAreaChange里监听

分享
微博
QQ
微信
回复
2024-12-18 19:02:47
相关问题
HarmonyOS sdk中没有gssapi这个
420浏览 • 1回复 待解决
HarmonyOS 旋转屏幕后显示不正常
599浏览 • 1回复 待解决
HarmonyOS listItem问题
462浏览 • 1回复 待解决