1
- import { Transition } from 'vue' ;
1
+ import { Transition , inject } from 'vue' ;
2
2
import CloseOutlined from '@ant-design/icons-vue/CloseOutlined' ;
3
3
import PropTypes from '../_util/vue-types' ;
4
4
import getTransitionProps from '../_util/getTransitionProps' ;
5
- import omit from 'omit.js' ;
6
5
import Wave from '../_util/wave' ;
7
- import { hasProp , getListeners , getOptionProps } from '../_util/props-util' ;
6
+ import { hasProp , getOptionProps } from '../_util/props-util' ;
8
7
import BaseMixin from '../_util/BaseMixin' ;
9
8
import { ConfigConsumerProps } from '../config-provider' ;
10
9
import warning from '../_util/warning' ;
@@ -29,19 +28,17 @@ const PresetColorRegex = new RegExp(`^(${PresetColorTypes.join('|')})(-inverse)?
29
28
export default {
30
29
name : 'ATag' ,
31
30
mixins : [ BaseMixin ] ,
32
- model : {
33
- prop : 'visible' ,
34
- event : 'close.visible' ,
35
- } ,
36
31
props : {
37
32
prefixCls : PropTypes . string ,
38
33
color : PropTypes . string ,
39
34
closable : PropTypes . bool . def ( false ) ,
40
35
visible : PropTypes . bool ,
41
36
afterClose : PropTypes . func ,
42
37
} ,
43
- inject : {
44
- configProvider : { default : ( ) => ConfigConsumerProps } ,
38
+ setup ( ) {
39
+ return {
40
+ configProvider : inject ( 'configProvider' , ConfigConsumerProps ) ,
41
+ } ;
45
42
} ,
46
43
data ( ) {
47
44
let _visible = true ;
@@ -68,7 +65,7 @@ export default {
68
65
methods : {
69
66
setVisible ( visible , e ) {
70
67
this . $emit ( 'close' , e ) ;
71
- this . $emit ( 'close. visible' , false ) ;
68
+ this . $emit ( 'update: visible' , false ) ;
72
69
const afterClose = this . afterClose ;
73
70
if ( afterClose ) {
74
71
// next version remove.
@@ -120,16 +117,11 @@ export default {
120
117
121
118
render ( ) {
122
119
const { prefixCls : customizePrefixCls } = this . $props ;
123
- const getPrefixCls = this . configProvider ( ) . getPrefixCls ;
120
+ const getPrefixCls = this . configProvider . getPrefixCls ;
124
121
const prefixCls = getPrefixCls ( 'tag' , customizePrefixCls ) ;
125
122
const { _visible : visible } = this . $data ;
126
123
const tag = (
127
- < span
128
- v-show = { visible }
129
- { ...{ on : omit ( getListeners ( this ) , [ 'close' ] ) } }
130
- class = { this . getTagClassName ( prefixCls ) }
131
- style = { this . getTagStyle ( ) }
132
- >
124
+ < span v-show = { visible } class = { this . getTagClassName ( prefixCls ) } style = { this . getTagStyle ( ) } >
133
125
{ this . $slots . default ( ) }
134
126
{ this . renderCloseIcon ( ) }
135
127
</ span >
0 commit comments