Skip to content

Tag 标签

代码演示

基础用法

vue
<script setup></script>

<template>
  <a-space>
    <x-tag> 爱在西元前</x-tag>
    <x-tag type="success">
      不该
    </x-tag>
    <x-tag type="warning">
      超人不会飞
    </x-tag>
    <x-tag type="error">
      手写的从前
    </x-tag>
    <x-tag type="info">
      哪里都是你
    </x-tag>
  </a-space>
</template>

<style lang="less" scoped></style>

无边框

vue
<script setup></script>

<template>
  <a-space>
    <x-tag :bordered="false">
      爱在西元前
    </x-tag>
    <x-tag
      :bordered="false"
      type="success"
    >
      不该
    </x-tag>
    <x-tag
      :bordered="false"
      type="warning"
    >
      超人不会飞
    </x-tag>
    <x-tag
      :bordered="false"
      type="error"
    >
      手写的从前
    </x-tag>
    <x-tag
      :bordered="false"
      type="info"
    >
      哪里都是你
    </x-tag>
  </a-space>
</template>

<style lang="less" scoped></style>

可关闭

vue
<script setup>
import { message } from 'ant-design-vue'

function handleClick() {
  message.info('tag click')
}

function handleClose() {
  message.info('tag close')
}
</script>

<template>
  <a-space>
    <x-tag
      closable
      @close="handleClose"
    >
      爱在西元前
    </x-tag>
    <x-tag
      closable
      type="success"
      @close="handleClose"
    >
      不该
    </x-tag>
    <x-tag
      closable
      type="warning"
      @close="handleClose"
    >
      超人不会飞
    </x-tag>
    <x-tag
      closable
      type="error"
      @close="handleClose"
    >
      手写的从前
    </x-tag>
    <x-tag
      closable
      type="info"
      @click="handleClick"
      @close="handleClose"
    >
      哪里都是你
    </x-tag>
  </a-space>
</template>

<style lang="less" scoped></style>

形状

vue
<script setup>
import { message } from 'ant-design-vue'

function handleClose() {
  message.info('tag close')
}
</script>

<template>
  <a-space>
    <x-tag
      closable
      round
      size="small"
      type="success"
      @close="handleClose"
    >
      不该
    </x-tag>
    <x-tag
      closable
      round
      type="error"
      @close="handleClose"
    >
      手写的从前
    </x-tag>
    <x-tag
      closable
      round
      size="large"
      type="error"
      @close="handleClose"
    >
      手写的从前
    </x-tag>
  </a-space>
</template>

<style lang="less" scoped></style>

颜色

vue
<script setup></script>

<template>
  <x-tag
    border-color="#555"
    color="#BBB"
    text-color="#555"
  >
    告别夜晚 等待天亮
  </x-tag>
</template>

<style lang="less" scoped></style>

次要标签

vue
<script setup></script>

<template>
  <a-space>
    <x-tag
      secondary
      type="success"
    >
      不该
    </x-tag>
    <x-tag
      secondary
      type="warning"
    >
      超人不会飞
    </x-tag>
    <x-tag
      secondary
      type="error"
    >
      手写的从前
    </x-tag>
    <x-tag
      secondary
      type="info"
    >
      哪里都是你
    </x-tag>
  </a-space>
</template>

<style lang="less" scoped></style>

API

Props

参数说明类型默认值
type按钮类型,可选:default、primary、info、success、warning、errorstringdefault
color颜色string-
text-color文本颜色string-
border-color边框颜色string-
icon图标VNode-
secondary次要标签booleanfalse
bordered是否显示边框booleantrue
round是否圆形标签booleanfalse

Slots

名称说明
icon图标

本文档内容版权为 XYAdmin 作者所有,保留所有权利。