Skip to content
On this page
你当前查看的文档是tmui3.2.0(已不再支持NVUE)
[tmui3.1.x nvue点我] [tmui4.x uniappx原生开发代替nvue]

展示组件

角标 TmBadge

角标,位置丰富。

🌶️ 示例

查看模拟效果
示例模板
vue
<template>

	<tm-sheet>
		<tm-text font-size="32" class=" text-weight-b mb-16 d-block">角标 Badge</tm-text>
		<tm-text color="#999999">
			内联模式布局,方便角标布局和排版。
		</tm-text>
	</tm-sheet>

	<tm-sheet class="flex flex-row flex-row-center-center flex-wrap ">

		<view class="flex-1 flex flex-row flex-row-center-center ">
			<tm-badge :label="true">
				<view style="width: 100rpx;height:100rpx;background: #f3f3f3;"></view>
			</tm-badge>
		</view>
		<view class="flex-1 flex flex-row flex-row-center-center">
			<tm-badge bg-color="danger" :label="1">
				<view style="width: 100rpx;height:100rpx;background: #f3f3f3;"></view>
			</tm-badge>
		</view>

		<view class="flex-1 flex flex-row flex-row-center-center">
			<tm-badge bg-color="success" label="HOT">
				<view style="width: 100rpx;height:100rpx;background: #f3f3f3;"></view>
			</tm-badge>
		</view>
		<view class="flex-1 flex flex-row flex-row-center-center">
			<tm-badge bg-color="primary" :label="150">
				<view style="width: 100rpx;height:100rpx;background: #f3f3f3;"></view>
			</tm-badge>

		</view>
	</tm-sheet>

	<tm-sheet>
		<tm-text font-size="32" class=" text-weight-b ">左上,右上,左下,右下,上中,下中</tm-text>
	</tm-sheet>

	<tm-sheet class="flex flex-row flex-row-center-center flex-wrap  gap-16">

		<tm-badge position="left" :label="true">
			<view style="width: 100rpx;height:100rpx;background: #f3f3f3;"></view>
		</tm-badge>
		<tm-badge position="right" bg-color="danger" :label="36">
			<view style="width: 100rpx;height:100rpx;background: #f3f3f3;"></view>
		</tm-badge>
		<tm-badge position="bottomLeft" bg-color="success" label="HOT">
			<view style="width: 100rpx;height:100rpx;background: #f3f3f3;"></view>
		</tm-badge>
		<tm-badge position="bottomRight" bg-color="primary" :label="150">
			<view style="width: 100rpx;height:100rpx;background: #f3f3f3;"></view>
		</tm-badge>
		<tm-badge position="top" bg-color="success" label="HOT">
			<view style="width: 100rpx;height:100rpx;background: #f3f3f3;"></view>
		</tm-badge>
		<tm-badge position="bottom" bg-color="error" :label="150">
			<view style="width: 100rpx;height:100rpx;background: #f3f3f3;"></view>
		</tm-badge>
	</tm-sheet>

	<tm-sheet>
		<tm-text font-size="32" class=" text-weight-b d-block">应用在其它组件上</tm-text>
	</tm-sheet>
	<tm-sheet class="flex flex-row flex-row-center-center gap-19">

		<tm-badge label="50%SALE">
			<tm-button>按钮</tm-button>
		</tm-badge>
		<tm-badge label="HOT">
			<tm-icon name="ancient-gate-fill"></tm-icon>
		</tm-badge>
		<tm-badge  :label="true">
			<tm-icon name="verified-badge-fill"></tm-icon>

		</tm-badge>

	</tm-sheet>

	<view class="py-32"></view>
</template>

<script lang="ts" setup>
import { ref } from "vue"
</script>

<style></style>

🌶️ 兼容性

平台兼容

H5uniAPP小程序version
☑️☑️☑️☑️

🌱 参数

参数名类型默认值描述
fontSizestring|number"20"-
bgColorstring"error"-
fontColorstring"white"-
maxCountstring|number99-
labelstring|number|boolean""如果是boolean就显示角标小红点如果是string显示文本标签如果是数字显示数字并启用maxCount
positionstring"right"-
offsetnumber[]():number[]=>[0,0]asnumber[]-

🌹 事件

事件名参数返回数据描述

🌽 slot插槽

插槽名数据描述
default-默认内容插槽

🥗 ref方法

方法名参数返回值描述