

English
Lottie animation components, animation resource reference Lottie official link.
animation-view组件是uts组件,需下载插件:animation-view,仅app平台 nvue/uvue 页面支持
uts组件需 HBuilderX 3.7.0+
本地编译需要 gradle 7.5 及以上版本
app平台真机运行需要打自定义基座
Platform Difference Description
App | H5 | 微信小程序 | 支付宝小程序 | 百度小程序 | 抖音小程序、飞书小程序 | QQ小程序 | 快应用 | 360小程序 | 快手小程序 | 京东小程序 | 元服务 | 小红书小程序 |
---|---|---|---|---|---|---|---|---|---|---|---|---|
√ | x | x | x | √ | x | x | x | x | x | x | x | x |
HarmonyOS
HarmonyOS |
---|
x |
Attribute Description
Property Name | Type | Default Value | Description |
---|---|---|---|
path | String | animation resource address, support local path and network path | |
loop | Boolean | false | Whether the animation is played in a loop |
autoplay | Boolean | true | Whether the animation is played automatically |
action | String | play | animation operation, possible values are play, pause, stop |
hidden | Boolean | true | whether to hide the animation |
@bindended | EventHandle | The ended event is triggered when the playback reaches the end (the callback will be triggered when the natural playback ends, and the end of the loop playback and manual stop animation will not be triggered) |
注意
code example
<template>
<view>
<animation-view class="animation" :path="path" :loop="loop" :autoplay="autoplay" :action="action"
:hidden="hidden" @bindended="lottieEnd">
</animation-view>
<button @click="playLottie" type="primary">{{status}}lottie动画</button>
</view>
</template>
<script>
export default {
data() {
return {
path: '/uni_modules/uni-animation-view/static/lottie.json',
loop: false,
autoplay: true,
action: 'stop',
hidden: false,
}
},
methods: {
playLottie() {
this.action = ('play' !== this.action) ? 'play' : 'pause';
},
lottieEnd() {
this.action = 'stop';
}
}
}
</script>
<style>
.animation {
width: 750rpx;
height: 300rpx;
background-color: #FF0000;
margin-bottom: 20px;
}
</style>