Tag 标签

Tag 说明

进行简单的标记

Tag innerHTML 示例

>{}
<template>
  <div>
    <Tag
      v-for="(item, index) in the.tag.css"
      :key="index"
      :named="index"
      :css="item"
      closable
      @onEvent="onTagEvent"
    >
      {{ item }}
    </Tag>
  </div>
</template>

<script>
// import { reactive } from 'vue';

export default {
  setup(props, context) {
    // 使用外挂方式引入,具体查看demo
    const $plus = window.$plus;
    const reactive = $plus.vue.reactive;

    const the = reactive({
      tag: {
        key: '',
        css: ['default', 'info', 'primary', 'success', 'error', 'warning'],
      },
    });

    /** 标签事件 */
    const onTagEvent = (resp) => {
      switch (resp.cmd) {
        case 'close':
          // 关闭
          the.tag.css.splice(parseInt(resp.named), 1);
          break;
        case 'click':
          $plus.message.info(resp.event.target.innerHTML + ':' + resp.named);
          // console.log('onTagEvent:', resp.named, resp.event.target.innerHTML);
          // $plus.router.push('/Api/ClassTree/' + resp.named + '?title=' + resp.event.target.innerHTML)
          break;
        default:
          console.log('onTagEvent:', resp);
          break;
      }
    };
    return { the, onTagEvent };
  },
};
</script>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52

Tag Props

属性说明类型默认值
named 0.4.2组件命名,配合 v-for,并支持关闭事件String,Numbertag
css标签的颜色,可选default, info, primary, success, error, warningStringdefault
closable是否可以关闭Booleanfalse

Tag Events

属性说明返回值
onEvent点击事件Json

Events cmd click

  • 点击触发
参数名说明类型
named组件命名String,Number
event点击事件回调Object

Events cmd close

  • 关闭触发
参数名说明类型
named组件命名String,Number

Last Updated: