Tag 标签

引入

app.jsonindex.json中引入组件,详细介绍见快速上手

  1. "usingComponents": {
  2. "van-tag": "path/to/@vant/weapp/dist/tag/index"
  3. }

代码演示

基础用法

通过type属性控制标签颜色,默认为灰色

  1. <van-tag>标签</van-tag>
  2. <van-tag type="primary">标签</van-tag>
  3. <van-tag type="success">标签</van-tag>
  4. <van-tag type="danger">标签</van-tag>
  5. <van-tag type="warning">标签</van-tag>

空心样式

设置plain属性设置为空心样式

  1. <van-tag plain>标签</van-tag>
  2. <van-tag plain type="primary">标签</van-tag>
  3. <van-tag plain type="success">标签</van-tag>
  4. <van-tag plain type="danger">标签</van-tag>
  5. <van-tag plain type="warning">标签</van-tag>

圆角样式

通过round设置为圆角样式

  1. <van-tag round>标签</van-tag>
  2. <van-tag round type="primary">标签</van-tag>
  3. <van-tag round type="success">标签</van-tag>
  4. <van-tag round type="danger">标签</van-tag>
  5. <van-tag round type="warning">标签</van-tag>

标记样式

通过mark设置为标记样式(半圆角)

  1. <van-tag mark>标签</van-tag>
  2. <van-tag mark type="primary">标签</van-tag>
  3. <van-tag mark type="success">标签</van-tag>
  4. <van-tag mark type="danger">标签</van-tag>
  5. <van-tag mark type="warning">标签</van-tag>

自定义颜色

  1. <van-tag color="#f2826a">标签</van-tag>
  2. <van-tag color="#f2826a" plain>标签</van-tag>
  3. <van-tag color="#7232dd">标签</van-tag>
  4. <van-tag color="#7232dd" plain>标签</van-tag>
  5. <van-tag color="#ffe1e1" text-color="#ad0000">标签</van-tag>

标签大小

  1. <van-tag type="danger">标签</van-tag>
  2. <van-tag type="danger" size="medium">标签</van-tag>
  3. <van-tag type="danger" size="large">标签</van-tag>

API

Props

参数说明类型默认值版本
type类型,可选值为primary success danger warningstring--
size大小, 可选值为large mediumstring--
color标签颜色string--
plain是否为空心样式booleanfalse-
round是否为圆角样式booleanfalse-
mark是否为标记样式booleanfalse-
text-color文本颜色,优先级高于color属性stringwhite-

Slot

名称说明
-自定义 Tag 显示内容

外部样式类

类名说明
custom-class根节点样式类

Tag 标记 - 图1