Skeleton
组件类型:UxSkeletonComponentPublicInstance
此组件仅是占位显示,需要辉光效果请用ux-shimmer插件包裹
平台兼容性
UniApp X
Android | iOS | web | 鸿蒙 Next | 小程序 |
---|---|---|---|---|
√ | √ | √ | x | √ |
UniApp Vue Nvue
Android | iOS | web | 鸿蒙 Next | 小程序 |
---|---|---|---|---|
x | x | √ | x | x |
Props
属性名 | 类型 | 默认值 | 说明 |
---|---|---|---|
rows | Array | '100%' | 段落占位图行数,值是宽度 |
height | Array | [18] | 段落高度 |
spacing | Any | 5 | 段落间隔 |
avatar | Boolean | 32 | 显示头像 |
avatarWidth | Any | 32 | 头像宽度 |
avatarHeight | Any | 32 | 头像高度 |
shape | String | square | 头像占位图的形状 |
background | String | #e9e9e9 | 段落背景色 |
margin | Array | 边距[上右下左][上下左右][上下左右] | |
mt | Any | 距上单位px | |
mr | Any | 距右单位px | |
mb | Any | 距下单位px | |
ml | Any | 距左单位px | |
padding | Array | 填充[上右下左][上下左右][上下左右] | |
pt | Any | 上内边距单位px | |
pr | Any | 右内边距单位px | |
pb | Any | 下内边距单位px | |
pl | Any | 左内边距单位px | |
xstyle | Array | 自定义样式 |
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>