Skip to content
本页导读

Card

组件类型:UxCardComponentPublicInstance

支持图标、标题、副标题及样式自定义,支持内边距和外边距设置,可显示阴影和边框

平台兼容性

UniApp X

AndroidiOSweb鸿蒙 Next小程序
x

UniApp Vue Nvue

AndroidiOSweb鸿蒙 Next小程序
xxxx

Props

属性名类型默认值说明
directionString布局方向
titleString标题
sizeAny$ux.Conf.fontSize标题大小
colorString$ux.Conf.fontColor标题颜色
darkColorString深色none-不显示,auto-自动适配深色模式,其他-颜色
boldBooleanfalse标题加粗
titleStyleString标题样式
subtitleString副标题
subtitleColorString$ux.Conf.secondaryColor副标题颜色
subtitleSizeAny$ux.Conf.fontColor.small副标题大小
subtitleStyleString副标题样式
iconString标题图标
iconColorString$ux.Conf.fontColor标题图标颜色
iconSizeAny$ux.Conf.fontSize标题图标大小
iconStyleString标题图标样式
customFontString自定义字体路径
customFamilyString自定义字体family
backgroundString$ux.Conf.backgroundColor背景色
backgroundDarkStringauto深色none-不显示,auto-自动适配深色模式,其他-颜色
showBlurBooleanfalse开启模糊背景
blurRadiusNumber10模糊半径
blurColorStringrgba(255,255,255,0.3)模糊颜色
shadowBooleanfalse显示阴影
borderBooleanfalse显示边框
borderColorString$ux.Conf.borderColor边框颜色
borderDarkColorStringauto深色none-不显示,auto-自动适配深色模式,其他-颜色
radiusAny$ux.Conf.radius圆角
paddingAny$ux.Conf.padding内部水平边距
marginAny$ux.Conf.margin边距
xstyleArray自定义样式

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>