Skip to content

Tag 标签

iPhone

此组件一般用于标记和选择,我们提供了更加丰富的表现形式,能够较全面的涵盖您的使用场景,特点如下:

  • 通过 shape 属性设置多种形状,circle 两边半圆形, square 方形,带圆角
  • 通过 type 属性设置5种主题,primarysuccesswarningerrorinfo
  • 通过 plain 属性设置是否镂空
  • 通过 plainFill 属性设置镂空时,是否填充背景色(默认 false)

平台差异说明

APPH5微信小程序支付宝小程序QQ小程序···
适配中

代码示例

部分功能示例,具体可参考示例程序以及文档API。

基础用法

  • 通过 type 属性设置主题类型,默认为 primary
  • 通过 text 属性设置标签内容
html
<fu-tag text="扶摇直上" type="success"></fu-tag>

设置标签形状

  • 通过 shape 属性设置标签的形状,默认为 square(方形,带圆角),可选:circle(两边半圆形)
html
<fu-tag text="秋水入海" shape="circle"></fu-tag>

设置标签是否可以关闭

  • 通过 closable 属性设置为 true,会在标签上自动添加一个关闭图标,默认为 false
  • 设置可关闭后,点击关闭按钮,会触发 close 事件,回调中手动设置 show 属性为 false 即可隐藏标签
html
<template>
    <fu-tag text="秋水共长天一色" :show="show" closable @close="handleClose"></fu-tag>
</template>

<script setup>
    import { ref } from 'vue';

    // data数据
    let show = ref(true);

    // methods方法
    const handleClose = () => {
        show.value = false;
    };
</script>

API

Tag Props

属性名说明类型默认值可选值
index用于标识标签,点击标签时,会通过 click 事件返回此值String|Number--
show标签是否显示Booleantruefalse
type标签的主题类型Stringprimarysuccess/warning/error/info
disabled标签是否禁用Booleanfalsetrue
shape标签的形状Stringsquarecircle
size标签的大小Stringmediumlarge/mini
text标签的文本内容String--
bgColor标签的背景色String--
color标签的字体颜色String--
borderColor标签的边框颜色String--
closeColor标签的关闭图标颜色String--
plainFill镂空标签是否填充背景色Booleanfalsetrue
plain是否镂空Booleanfalsetrue
closable是否可关闭,设置为 true 文字右边会出现一个关闭图标Booleanfalsetrue
icon内置图标String--
iconColor内置图标颜色String--

Tag Events

事件名说明回调参数
click点击标签时触发() => void
closecloseabletrue 时,点击关闭图标时触发() => void

Tag Slot

名称说明
icon自定义左侧标签的图标/图片