Card
组件类型:UxCardComponentPublicInstance
支持图标、标题、副标题及样式自定义,支持内边距和外边距设置,可显示阴影和边框
平台兼容性
UniApp X
Android | iOS | web | 鸿蒙 Next | 小程序 |
---|---|---|---|---|
√ | √ | √ | x | √ |
UniApp Vue Nvue
Android | iOS | web | 鸿蒙 Next | 小程序 |
---|---|---|---|---|
x | x | √ | x | x |
Props
属性名 | 类型 | 默认值 | 说明 |
---|---|---|---|
direction | String | 布局方向 | |
title | String | 标题 | |
size | Any | $ux.Conf.fontSize | 标题大小 |
color | String | $ux.Conf.fontColor | 标题颜色 |
darkColor | String | 深色none-不显示,auto-自动适配深色模式,其他-颜色 | |
bold | Boolean | false | 标题加粗 |
titleStyle | String | 标题样式 | |
subtitle | String | 副标题 | |
subtitleColor | String | $ux.Conf.secondaryColor | 副标题颜色 |
subtitleSize | Any | $ux.Conf.fontColor.small | 副标题大小 |
subtitleStyle | String | 副标题样式 | |
icon | String | 标题图标 | |
iconColor | String | $ux.Conf.fontColor | 标题图标颜色 |
iconSize | Any | $ux.Conf.fontSize | 标题图标大小 |
iconStyle | String | 标题图标样式 | |
customFont | String | 自定义字体路径 | |
customFamily | String | 自定义字体family | |
background | String | $ux.Conf.backgroundColor | 背景色 |
backgroundDark | String | auto | 深色none-不显示,auto-自动适配深色模式,其他-颜色 |
showBlur | Boolean | false | 开启模糊背景 |
blurRadius | Number | 10 | 模糊半径 |
blurColor | String | rgba(255,255,255,0.3) | 模糊颜色 |
shadow | Boolean | false | 显示阴影 |
border | Boolean | false | 显示边框 |
borderColor | String | $ux.Conf.borderColor | 边框颜色 |
borderDarkColor | String | auto | 深色none-不显示,auto-自动适配深色模式,其他-颜色 |
radius | Any | $ux.Conf.radius | 圆角 |
padding | Any | $ux.Conf.padding | 内部水平边距 |
margin | Any | $ux.Conf.margin | 边距 |
xstyle | Array | 自定义样式 |
direction
值 | 说明 |
---|---|
row水平 | |
column垂直 |
darkColor
值 | 说明 |
---|---|
none不显示 | |
auto自动适配深色模式 | |
color其他颜色 |
backgroundDark
值 | 说明 |
---|---|
none不显示 | |
auto自动适配深色模式 | |
color其他颜色 |
borderDarkColor
值 | 说明 |
---|---|
none不显示 | |
auto自动适配深色模式 | |
color其他颜色 |
示例代码
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" :border="border" icon="arrowright" title="标题" subtitle="副标题" subtitle-color="green" :bold="true">
<ux-text text="可设置标题、副标题及样式" :mb="15"></ux-text>
<ux-row>
<view class="b1" @click="border = true"></view>
<view class="b2" @click="border = false"></view>
<view class="b1"></view>
</ux-row>
</ux-card>
<ux-card direction="column" icon="arrowright" title="边距" :bold="true" :margin="30">
<ux-text text="支持内边距和外边距设置" :mb="15"></ux-text>
<ux-row>
<view class="b1"></view>
<view class="b2"></view>
<view class="b1"></view>
</ux-row>
</ux-card>
<ux-card direction="column" icon="arrowright" title="边框" :bold="true" :border="true">
<ux-text text="支持显示边框" :mb="15"></ux-text>
<ux-row>
<view class="b1"></view>
<view class="b2"></view>
<view class="b1"></view>
</ux-row>
</ux-card>
<view style="position: relative;">
<image class="blur-bg" src="/uni_modules/ux-frame/static/404.png" mode="top"></image>
<ux-card direction="column" icon="arrowright" title="模糊" :showBlur="true" :blur="100" :bold="true">
<ux-text text="支持自定义插槽模糊背景" :mb="15"></ux-text>
<ux-row>
<view class="b1"></view>
<view class="b2"></view>
<view class="b1"></view>
</ux-row>
</ux-card>
</view>
<ux-card direction="column" icon="arrowright" title="阴影" :bold="true" :shadow="true">
<ux-text text="支持显示阴影" :mb="15"></ux-text>
<ux-row>
<view class="b1"></view>
<view class="b2"></view>
<view class="b1"></view>
</ux-row>
</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" :border="border" icon="arrowright" title="标题" subtitle="副标题" subtitle-color="green" :bold="true">
<ux-text text="可设置标题、副标题及样式" :mb="15"></ux-text>
<ux-row>
<view class="b1" @click="border = true"></view>
<view class="b2" @click="border = false"></view>
<view class="b1"></view>
</ux-row>
</ux-card>
<ux-card direction="column" icon="arrowright" title="边距" :bold="true" :margin="30">
<ux-text text="支持内边距和外边距设置" :mb="15"></ux-text>
<ux-row>
<view class="b1"></view>
<view class="b2"></view>
<view class="b1"></view>
</ux-row>
</ux-card>
<ux-card direction="column" icon="arrowright" title="边框" :bold="true" :border="true">
<ux-text text="支持显示边框" :mb="15"></ux-text>
<ux-row>
<view class="b1"></view>
<view class="b2"></view>
<view class="b1"></view>
</ux-row>
</ux-card>
<view style="position: relative;">
<image class="blur-bg" src="/uni_modules/ux-frame/static/404.png" mode="top"></image>
<ux-card direction="column" icon="arrowright" title="模糊" :showBlur="true" :blur="100" :bold="true">
<ux-text text="支持自定义插槽模糊背景" :mb="15"></ux-text>
<ux-row>
<view class="b1"></view>
<view class="b2"></view>
<view class="b1"></view>
</ux-row>
</ux-card>
</view>
<ux-card direction="column" icon="arrowright" title="阴影" :bold="true" :shadow="true">
<ux-text text="支持显示阴影" :mb="15"></ux-text>
<ux-row>
<view class="b1"></view>
<view class="b2"></view>
<view class="b1"></view>
</ux-row>
</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'
const title = ref('')
const border = ref(false)
const showDoc = ref(false)
function onDoc() {
plus.openWeb({
title: '在线文档',
url: 'https://www.uxframe.cn/component/card.html',
// blur: 1,
success: () => {
showDoc.value = true
},
complete: () => {
showDoc.value = false
}
})
}
onLoad((e) => {
title.value = e['title'] ?? ''
})
</script>
<script setup>
import * as plus from '@/uni_modules/ux-plus'
const title = ref('')
const border = ref(false)
const showDoc = ref(false)
function onDoc() {
plus.openWeb({
title: '在线文档',
url: 'https://www.uxframe.cn/component/card.html',
// blur: 1,
success: () => {
showDoc.value = true
},
complete: () => {
showDoc.value = false
}
})
}
onLoad((e) => {
title.value = e['title'] ?? ''
})
</script>
css
<style lang="scss">
.b1 {
margin-right: 10px;
width: 50px;
height: 40px;
border-radius: 5px;
background-color: #3491FA;
}
.b2 {
margin-right: 10px;
width: 50px;
height: 40px;
border-radius: 5px;
background-color: #165DFF;
}
.blur-bg {
position: absolute;
width: 100%;
height: 100%;
}
</style>
<style lang="scss">
.b1 {
margin-right: 10px;
width: 50px;
height: 40px;
border-radius: 5px;
background-color: #3491FA;
}
.b2 {
margin-right: 10px;
width: 50px;
height: 40px;
border-radius: 5px;
background-color: #165DFF;
}
.blur-bg {
position: absolute;
width: 100%;
height: 100%;
}
</style>