Tag 标签

该组件目前处于实验性状态,需要进行更加严密的测试,API 也可能发生比较大的变动

Forget about the Price Tag

import { DuTag } from 'dangoui'

示例

<template>
  <PreviewBlock title="大小">
    <DuTag size="mini" @click="handleClick">标签</DuTag>
    <DuTag size="small" @click="handleClick">标签</DuTag>
    <DuTag @click="handleClick">标签</DuTag>
    <DuTag size="medium" @click="handleClick">标签</DuTag>
    <DuTag size="large" @click="handleClick">标签</DuTag>
  </PreviewBlock>
  <PreviewBlock title="不同类型">
    <DuTag>标签</DuTag>
    <DuTag bg="solid" icon="lock">标签</DuTag>
    <DuTag round>标签</DuTag>
    <DuTag bordered>标签</DuTag>
    <DuTag size="small" bordered bg="ghost" icon="lock">标签</DuTag>
    <DuTag size="mini" bordered bg="ghost">标签</DuTag>
    <DuTag size="mini" bordered bg="ghost" round>标签</DuTag>
    <DuTag size="mini" bg="solid">标签</DuTag>
  </PreviewBlock>
  <PreviewBlock title="带图标">
    <DuTag size="mini" icon="lock">标签</DuTag>
    <DuTag size="small" icon="lock">标签</DuTag>
    <DuTag icon="lock">标签</DuTag>
  </PreviewBlock>
  <PreviewBlock title="可关闭">
    <DuTag size="small" closeable @close="handleClose">标签</DuTag>
    <DuTag closeable @close="handleClose">标签</DuTag>
  </PreviewBlock>
  <PreviewBlock title="内置颜色">
    <DuTag color="primary">标签</DuTag>
    <DuTag color="secondary">标签</DuTag>
    <DuTag color="success">标签</DuTag>
    <DuTag color="warning">标签</DuTag>
    <DuTag color="error">标签</DuTag>
    <DuTag color="default">标签</DuTag>
  </PreviewBlock>
  <PreviewBlock title="自定义颜色">
    <DuTag color="#B2D600" icon="lock" closeable>标签</DuTag>
    <DuTag color="#B2D600" icon="lock" bordered closeable>标签</DuTag>
    <DuTag color="#B2D600" icon="lock" bordered bg="ghost" closeable>标签</DuTag>
    <DuTag color="#B2D600" icon="lock" bordered bg="solid" closeable>标签</DuTag>
  </PreviewBlock>
</template>

<script setup lang="ts">
import { DuTag } from 'dangoui'

function handleClose() {
  console.log('[demo] close')
}

function handleClick() {
  console.log('[demo] click')
}
</script>
0

API

属性

属性名类型默认值说明
colorstring | { border: string; text: string; background: string; }"primary"颜色,可以使用主题预置的颜色或者十六进制颜色表示,也可以使用对象更灵活地来自定义颜色 TODO: 抽象到公用类型中,并可以外部扩展,这样就能进行主题定制与扩展
ext-classstring | string[] | Record<string, boolean>""
ext-stylestring | { [x: string]: string | number; }""
size"normal" | "mini" | "small" | "medium" | "large""normal"大小
roundbooleanfalse是否为圆角
borderedbooleanfalse是否带有边框
closeablebooleanfalse是否可关闭(显示一个关闭按钮)
bg"ghost" | "soft" | "solid""soft"实心、淡色、透明
iconstring - 左侧

插槽

名称
default

事件

名称类型
click(event: "click", event: any): void
close(event: "close"): void
本页包含