LottieViewDemo.ets
825 Bytes
import { AnimationItem } from '@ohos/lottie'
import { LottieView } from 'wdComponent/Index'
@Component
export struct LottieViewDemo {
@State
animateItem: AnimationItem | null = null
build() {
Column() {
Text('点击开始')
.fontSize(30)
.backgroundColor(Color.Blue)
.padding(20)
.fontColor(Color.White)
.borderRadius(10)
.fontWeight(500)
LottieView({
name: 'lottieDemo',
path: 'common/lottie/politeChicky.json',
onReady: (animateItem: AnimationItem | null) => {
this.animateItem = animateItem
},
onComplete: () => {
console.log('onComplete===')
}
})
}
.width(200)
.height(200)
.alignItems(HorizontalAlign.Center)
.backgroundImageSize(ImageSize.Cover)
}
}