diff --git a/src/tag/index.js b/src/tag/index.js index c3f438913..b941ca5c0 100644 --- a/src/tag/index.js +++ b/src/tag/index.js @@ -1,4 +1,4 @@ -import { Transition } from 'vue'; +import { computed, Transition } from 'vue'; import { createNamespace } from '../utils'; import Icon from '../icon'; @@ -26,36 +26,40 @@ export default createComponent({ emits: ['close'], setup(props, { slots, emit }) { - return function () { - const { type, mark, plain, color, round, size } = props; + const onClose = (event) => { + event.stopPropagation(); + emit('close'); + }; - const key = plain ? 'color' : 'backgroundColor'; - const style = { [key]: color }; + const style = computed(() => { + const key = props.plain ? 'color' : 'backgroundColor'; + const style = { [key]: props.color }; if (props.textColor) { style.color = props.textColor; } + }); + + return () => { + const { show, type, mark, plain, round, size, closeable } = props; const classes = { mark, plain, round }; if (size) { classes[size] = size; } - const CloseIcon = props.closeable && ( - { - event.stopPropagation(); - emit('close'); - }} - /> + const CloseIcon = closeable && ( + ); return ( - - {props.show ? ( - + + {show ? ( + {slots.default?.()} {CloseIcon}