readme.md 2.5 KB
Newer Older
DCloud-yyl's avatar
DCloud-yyl 已提交
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 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
## uts插件开发文档
[UTS 语法](https://uniapp.dcloud.net.cn/tutorial/syntax-uts.html)
[UTS API插件](https://uniapp.dcloud.net.cn/plugin/uts-plugin.html)
[UTS 组件插件](https://uniapp.dcloud.net.cn/plugin/uts-component.html)
[Hello UTS](https://gitcode.net/dcloud/hello-uts)


## animation-view

> animation-view组件是[uts插件](https://uniapp.dcloud.net.cn/plugin/uts-component.html),需 HBuilderX 3.7.0+

> 使用文档:[https://uniapp.dcloud.net.cn/component/animation-view.html](https://uniapp.dcloud.net.cn/component/animation-view.html)


### 属性说明

|属性名|类型|默认值|说明|
|:-|:-|:-|:-|
| path			| String		|		| 动画资源地址,支持本地路径和网络路径	|
| loop			| Boolean		| false	| 动画是否循环播放 					|
| autoplay		| Boolean		| true	| 动画是否自动播放					|
| action		| String		| play	| 动画操作,可取值 play、pause、stop	|
| hidden		| Boolean		| true	| 是否隐藏动画						|
| @bindended	| EventHandle	|		| 当播放到末尾时触发 ended 事件(自然播放结束会触发回调,循环播放结束及手动停止动画不会触发)	|


**注意**
* animation-view 仅App端nvue页面支持
* App端实现使用了Lottie三方SDK,参考开源项目:[Lottie for Android](https://github.com/airbnb/lottie-android)[Lottie for iOS](https://github.com/airbnb/lottie-ios)
* App-Android平台要求Android5(API Leavel 21)及以上系统
* App-iOS平台要求iOS11及以上版本系统


### 代码示例

```html
<template>
	<div>
		<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>
	</div>
</template>

<script>
	export default {
		data() {
			return {
				path: 'https://b.bdstatic.com/miniapp/images/lottie_example_one.json',
				loop: false,
				autoplay: false,
				action: 'play',
				hidden: false,
				status: '暂停'
			}
		},
		methods: {
			playLottie() {
				this.action = ('play' !== this.action) ? 'play' : 'pause';
				this.status = ('pause' === this.action) ? '播放' : '暂停';
			},
			lottieEnd() {
				this.status = '播放';
				this.action = 'stop';
				console.log('动画播放结束');
			}
		}
	}
</script>

<style>
	.animation {
		width: 750rpx;
		height: 300rpx;
		background-color: #FF0000;
		margin-bottom: 20px;
	}
</style>
```