Skip to content
本页导读

Lottie

组件类型:UxLottieComponentPublicInstance

平台兼容性

UniApp X

AndroidiOSweb鸿蒙 Next小程序
x

UniApp Vue Nvue

AndroidiOSweb鸿蒙 Next小程序
xxxx

Props

属性名类型默认值说明
srcString路径,只支持本地路径
loopBooleantrue循环播放
repeatNumber1重复次数
autoplayBooleantrue自动播放

Events

事件名说明参数
loaded加载成功时触发

示例代码

html
<template>
	<ux-page :stack="showDoc">
		<ux-navbar :title="title" :bold="true">
			<template v-slot:right>
				<!-- #ifndef MP -->
				<ux-button theme="text" icon="/static/tip.png" :icon-size="22" @click="onDoc()"></ux-button>
				<!-- #endif -->
			</template>
		</ux-navbar>
		
		<ux-scroll>
			<ux-card direction="column" icon="flag-filled" title="Lottie动画" :bold="true">
				<ux-text text="只支持本地路径,支持android、ios、web"></ux-text>
			</ux-card>
			
			<!-- #ifndef MP -->
			<ux-card direction="column" icon="arrowright" title="循环播放" :bold="true">
				<ux-lottie class="size" src="/static/loading.json"></ux-lottie>
			</ux-card>
			
			<ux-card direction="column" icon="arrowright" title="播放1次" :bold="true">
				<ux-lottie class="size" :repeat="1" :loop="false" src="/static/network.json"></ux-lottie>
			</ux-card>
			
			<ux-placeholder :height="300">
				<ux-row justify="center" align="center" style="height: 100%;">
					<ux-text prefix-icon="soapbubble-filled" text="真的没有了~"></ux-text>
				</ux-row>
			</ux-placeholder>
			<!-- #endif -->
			
			<!-- #ifdef MP -->
			<ux-placeholder :height="300">
				<ux-row justify="center" align="center" style="height: 100%;">
					<ux-text prefix-icon="soapbubble-filled" text="小程序不支持"></ux-text>
				</ux-row>
			</ux-placeholder>
			<!-- #endif -->
		</ux-scroll>
	</ux-page>
</template>
<template>
	<ux-page :stack="showDoc">
		<ux-navbar :title="title" :bold="true">
			<template v-slot:right>
				<!-- #ifndef MP -->
				<ux-button theme="text" icon="/static/tip.png" :icon-size="22" @click="onDoc()"></ux-button>
				<!-- #endif -->
			</template>
		</ux-navbar>
		
		<ux-scroll>
			<ux-card direction="column" icon="flag-filled" title="Lottie动画" :bold="true">
				<ux-text text="只支持本地路径,支持android、ios、web"></ux-text>
			</ux-card>
			
			<!-- #ifndef MP -->
			<ux-card direction="column" icon="arrowright" title="循环播放" :bold="true">
				<ux-lottie class="size" src="/static/loading.json"></ux-lottie>
			</ux-card>
			
			<ux-card direction="column" icon="arrowright" title="播放1次" :bold="true">
				<ux-lottie class="size" :repeat="1" :loop="false" src="/static/network.json"></ux-lottie>
			</ux-card>
			
			<ux-placeholder :height="300">
				<ux-row justify="center" align="center" style="height: 100%;">
					<ux-text prefix-icon="soapbubble-filled" text="真的没有了~"></ux-text>
				</ux-row>
			</ux-placeholder>
			<!-- #endif -->
			
			<!-- #ifdef MP -->
			<ux-placeholder :height="300">
				<ux-row justify="center" align="center" style="height: 100%;">
					<ux-text prefix-icon="soapbubble-filled" text="小程序不支持"></ux-text>
				</ux-row>
			</ux-placeholder>
			<!-- #endif -->
		</ux-scroll>
	</ux-page>
</template>
ts
<script setup>
	
	import * as plus from '@/uni_modules/ux-plus'
	
	const title = ref('')
	const showDoc = ref(false)
	
	function onDoc() {
		plus.openWeb({
			title: '在线文档',
			url: 'https://www.uxframe.cn/component/blur.html',
			// blur: 1,
			success: () => {
				showDoc.value = true
			},
			complete: () => {
				showDoc.value = false
			}
		})
	}
	
	onLoad((e: OnLoadOptions) => {
		title.value = e['title'] ?? ''
	})
</script>
<script setup>
	
	import * as plus from '@/uni_modules/ux-plus'
	
	const title = ref('')
	const showDoc = ref(false)
	
	function onDoc() {
		plus.openWeb({
			title: '在线文档',
			url: 'https://www.uxframe.cn/component/blur.html',
			// blur: 1,
			success: () => {
				showDoc.value = true
			},
			complete: () => {
				showDoc.value = false
			}
		})
	}
	
	onLoad((e: OnLoadOptions) => {
		title.value = e['title'] ?? ''
	})
</script>
css
<style lang="scss">
	.size {
		width: 120px;
		height: 120px;
	}
</style>
<style lang="scss">
	.size {
		width: 120px;
		height: 120px;
	}
</style>