Tag标签标记
引入
在app.json或index.json中引入组件,默认为ES6版本
"usingComponents": {
"vtu-tag": "/miniprogram_npm/vtuweapp/tag/vtu-tag"
}
代码演示
实心标签
<vtu-tag>标签</vtu-tag>
<vtu-tag bg-color="red" font-color="#fff">标签</vtu-tag>
<vtu-tag bg-color="orange" font-color="#fff">标签</vtu-tag>
<vtu-tag bg-color="#7e35bd" font-color="#fff" shape="circle">标签</vtu-tag>
<vtu-tag bg-color="#bd255c" font-color="#fff" shape="circle">标签</vtu-tag>
<vtu-tag bg-color="#1abf28" font-color="#fff" shape="circle">标签</vtu-tag>
<vtu-tag bg-color="#1f8fee" font-color="#fff" shape="round">标签</vtu-tag>
<vtu-tag bg-color="#ff7b8d" font-color="#fff" shape="round">标签</vtu-tag>
<vtu-tag bg-color="#fc973d" font-color="#fff" shape="round">标签</vtu-tag>
<vtu-tag bg-color="#f0f9eb" font-color="#67c23a" shape="round">标签</vtu-tag>
<vtu-tag bg-color="#fdf6ec" font-color="#e6a23c" shape="round">标签</vtu-tag>
标签尺寸
<vtu-tag>标签</vtu-tag>
<vtu-tag size="mini">标签</vtu-tag>
镂空标签
<vtu-tag type="out">标签</vtu-tag>
<vtu-tag type="out" bg-color="red">标签</vtu-tag>
<vtu-tag type="out" bg-color="orange">标签</vtu-tag>
<vtu-tag type="out" bg-color="#7e35bd" shape="circle">标签</vtu-tag>
<vtu-tag type="out" bg-color="#bd255c" shape="circle">标签</vtu-tag>
<vtu-tag type="out" bg-color="#1abf28" shape="circle">标签</vtu-tag>
<vtu-tag type="out" bg-color="#1f8fee" shape="round">标签</vtu-tag>
<vtu-tag type="out" bg-color="#ff7b8d" shape="round">标签</vtu-tag>
<vtu-tag type="out" bg-color="#fc973d" shape="round">标签</vtu-tag>
胶囊标签
<vtu-tag type="capsule" icon="iconfont icon-xihuanfill">标签</vtu-tag>
<vtu-tag type="capsule" icon="iconfont icon-xihuanfill" shape="circle" status="warning">标签</vtu-tag>
<vtu-tag type="capsule" icon="iconfont icon-xihuanfill" shape="round" size="mini" bg-color="red">标签</vtu-tag>
内置状态
<vtu-tag type="out" status="primary">默认</vtu-tag>
<vtu-tag status="primary">默认</vtu-tag>
<vtu-tag type="out" status="success">成功</vtu-tag>
<vtu-tag status="success">成功</vtu-tag>
<vtu-tag type="out" status="danger">危险</vtu-tag>
<vtu-tag status="danger">危险</vtu-tag>
<vtu-tag type="out" status="warning">警告</vtu-tag>
<vtu-tag status="warning">警告</vtu-tag>
可删除
<vtu-tag delete shape="circle" bind:click="click" data-label="上海" data-index="0">上海</vtu-tag>
<vtu-tag type="out" shape="circle" delete data-label="南京" data-index="1" bind:click="click">南京</vtu-tag>
<vtu-tag type="capsule" shape="circle" icon="iconfont icon-xihuanfill" delete data-label="北京" data-index="2" bind:click="click">北京</vtu-tag>
<vtu-tag delete shape="circle" size="mini" data-label="武汉" data-index="3" bind:click="click">武汉</vtu-tag>
Page({
data: {},
click: function(e) {
wx.showToast({
title: "正在删除[{0}]{1}标签".format(e.currentTarget.dataset.label, e.currentTarget.dataset.index),
icon: 'none',
duration: 2000
});
}
});
组件参数
Props
参数 | 说明 | 类型 | 默认值 | 必填 |
---|
type | 标签类型,default:实心/out:镂空/capsule:胶囊 | String | default | 否 |
size | 大小尺寸,small/mini | String | small | 否 |
font-color | 字体颜色 | String | - | 否 |
bg-color | 标签背景色 | String | - | 否 |
shape | 标签形状,round/circle | String | round | 否 |
status | 内置状态,primary/danger/warning/success | String | - | 否 |
icon | 图标 | String | - | 否 |
delete | 可删除 | Boolean | false | 否 |
Events
方法名 | 说明 | 参数 | 返回值 |
---|
bind:click | 点击事件 | - | 绑定的参数对象 |
外部样式类
外部样式类名 | 说明 |
---|
v-class | 组件外部样式类 |