Skip to content
本页导读

Skeleton

组件类型:UxSkeletonComponentPublicInstance

此组件仅是占位显示,需要辉光效果请用ux-shimmer插件包裹

平台兼容性

UniApp X

AndroidiOSweb鸿蒙 Next小程序
x

UniApp Vue Nvue

AndroidiOSweb鸿蒙 Next小程序
xxxx

Props

属性名类型默认值说明
rowsArray'100%'段落占位图行数,值是宽度
heightArray[18]段落高度
spacingAny5段落间隔
avatarBoolean32显示头像
avatarWidthAny32头像宽度
avatarHeightAny32头像高度
shapeStringsquare头像占位图的形状
backgroundString#e9e9e9段落背景色
marginArray边距[上右下左][上下左右][上下左右]
mtAny距上单位px
mrAny距右单位px
mbAny距下单位px
mlAny距左单位px
paddingArray填充[上右下左][上下左右][上下左右]
ptAny上内边距单位px
prAny右内边距单位px
pbAny下内边距单位px
plAny左内边距单位px
xstyleArray自定义样式

shape

说明
circle圆形
square方形

示例代码

html
<template>
	<ux-page :stack="showDoc">
		<ux-navbar :title="title" :border="false">
			<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="骨架屏" :bold="true">
				<ux-text text="支持头像占位、辉光效果"></ux-text>
			</ux-card>
			
			<ux-card direction="column" icon="arrowright" title="动态切换状态" :bold="true">
				<template #subtitle>
					<ux-switch :checked="loading" @change="change"></ux-switch>
				</template>
				
				<ux-shimmer v-if="loading">
					<ux-skeleton :rows="['100%', '60%', '40%']"></ux-skeleton>
				</ux-shimmer>
				<ux-col v-else>
					<ux-text text="我是第1行数据" :lineHeight="1.6"></ux-text>
					<ux-text text="我是第2行数据" :lineHeight="1.6"></ux-text>
					<ux-text text="我是第3行数据" :lineHeight="1.6"></ux-text>
				</ux-col>
			</ux-card>
			
			<ux-card direction="column" icon="arrowright" title="头像" :bold="true">
				<ux-text text="支持头像占位" :mb="15"></ux-text>
				
				<ux-shimmer>
					<ux-skeleton :avatar="true" shape="circle" :height="[20, 30, 50]" :rows="['100%', '100%', '100%']"></ux-skeleton>
				</ux-shimmer>
			</ux-card>
			
			<ux-placeholder :height="200">
				<ux-row justify="center" align="center" style="height: 100%;">
					<ux-text prefix-icon="soapbubble-filled" text="真的没有了~"></ux-text>
				</ux-row>
			</ux-placeholder>
		</ux-scroll>
		
	</ux-page>
</template>
<template>
	<ux-page :stack="showDoc">
		<ux-navbar :title="title" :border="false">
			<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="骨架屏" :bold="true">
				<ux-text text="支持头像占位、辉光效果"></ux-text>
			</ux-card>
			
			<ux-card direction="column" icon="arrowright" title="动态切换状态" :bold="true">
				<template #subtitle>
					<ux-switch :checked="loading" @change="change"></ux-switch>
				</template>
				
				<ux-shimmer v-if="loading">
					<ux-skeleton :rows="['100%', '60%', '40%']"></ux-skeleton>
				</ux-shimmer>
				<ux-col v-else>
					<ux-text text="我是第1行数据" :lineHeight="1.6"></ux-text>
					<ux-text text="我是第2行数据" :lineHeight="1.6"></ux-text>
					<ux-text text="我是第3行数据" :lineHeight="1.6"></ux-text>
				</ux-col>
			</ux-card>
			
			<ux-card direction="column" icon="arrowright" title="头像" :bold="true">
				<ux-text text="支持头像占位" :mb="15"></ux-text>
				
				<ux-shimmer>
					<ux-skeleton :avatar="true" shape="circle" :height="[20, 30, 50]" :rows="['100%', '100%', '100%']"></ux-skeleton>
				</ux-shimmer>
			</ux-card>
			
			<ux-placeholder :height="200">
				<ux-row justify="center" align="center" style="height: 100%;">
					<ux-text prefix-icon="soapbubble-filled" text="真的没有了~"></ux-text>
				</ux-row>
			</ux-placeholder>
		</ux-scroll>
		
	</ux-page>
</template>
ts
<script setup>
	
	
	import * as plus from '@/uni_modules/ux-plus'
	import { UxSwitchEvent } from '@/uni_modules/ux-frame';
	
	const title = ref('')
	const loading = ref(false)
	const showDoc = ref(false)
	
	function onDoc() {
		plus.openWeb({
			title: '在线文档',
			url: 'https://www.uxframe.cn/component/skeleton.html',
			// blur: 1,
			success: () => {
				showDoc.value = true
			},
			complete: () => {
				showDoc.value = false
			}
		})
	}
	
	onLoad((e) => {
		title.value = e['title'] ?? ''
	})
	
	function change(e: UxSwitchEvent) {
		loading.value = e.value
	}
</script>
<script setup>
	
	
	import * as plus from '@/uni_modules/ux-plus'
	import { UxSwitchEvent } from '@/uni_modules/ux-frame';
	
	const title = ref('')
	const loading = ref(false)
	const showDoc = ref(false)
	
	function onDoc() {
		plus.openWeb({
			title: '在线文档',
			url: 'https://www.uxframe.cn/component/skeleton.html',
			// blur: 1,
			success: () => {
				showDoc.value = true
			},
			complete: () => {
				showDoc.value = false
			}
		})
	}
	
	onLoad((e) => {
		title.value = e['title'] ?? ''
	})
	
	function change(e: UxSwitchEvent) {
		loading.value = e.value
	}
</script>
css
<style lang="scss">
	
</style>
<style lang="scss">
	
</style>