HarmonyOS 有出现动画,但没有消失动画

@Entry
@Component
struct Index {
  @State message: string = 'Hello World';
  @State flag: boolean = true
  build() {
    Stack() {
      if (this.flag) {
        Column() {
          Text(this.message)
            .id('HelloWorld')
            .fontColor(Color.Red)
            .fontSize(50)
            .fontWeight(FontWeight.Bold)
            .transition(TransitionEffect.translate({ y: 100 }).animation({ duration: 500 }))
        }
        // .transition(TransitionEffect.scale({ x: 0.5,y: 0.5 }).animation({ duration: 500 }))
      }
      Button('控制一下')
        .width(100)
        .height(100)
        .onClick(() => {
          this.flag = !this.flag
        })
    }
    .height('100%')
    .width('100%')
  }
}
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
HarmonyOS
2025-01-09 17:02:50
浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
fox280

父组件未设置transition,会直接下树子组件也会消失,所以没有动画。

分享
微博
QQ
微信
回复
2025-01-09 18:18:16
相关问题
Tabs 出现/消失转场动画效果
930浏览 • 1回复 待解决
HarmonyOS .scale没有动画效果
507浏览 • 1回复 待解决
动画如何做渲染一次不消失
8366浏览 • 1回复 待解决
HarmonyOS没有动画组件
896浏览 • 1回复 待解决
HarmonyOS 动画UpdateListener吗
312浏览 • 1回复 待解决
HarmonyOS 没有全局的api loading动画
1013浏览 • 1回复 待解决
实现一个自定义动画出现丢帧问题
868浏览 • 1回复 待解决
HarmonyOS canvas动画如何实现逐帧动画
659浏览 • 1回复 待解决
求助动画效果问题懂的吗?
4680浏览 • 1回复 待解决
HarmonyOS 加载动画
741浏览 • 1回复 待解决
HarmonyOS lottie动画
655浏览 • 1回复 待解决
HarmonyOS 动画实现
737浏览 • 1回复 待解决