inleft
2022-02-09 9bcb19959eeb9da9bde2561e7278f6d0a55eb151
commit | author | age
9bcb19 1 import { Tag } from 'ant-design-vue'
I 2 const { CheckableTag } = Tag
3
4 export default {
5   name: 'TagSelectOption',
6   props: {
7     prefixCls: {
8       type: String,
9       default: 'ant-pro-tag-select-option'
10     },
11     value: {
12       type: [String, Number, Object],
13       default: ''
14     },
15     checked: {
16       type: Boolean,
17       default: false
18     }
19   },
20   data () {
21     return {
22       localChecked: this.checked || false
23     }
24   },
25   watch: {
26     'checked' (val) {
27       this.localChecked = val
28     },
29     '$parent.items': {
30       handler: function (val) {
31         this.value && val.hasOwnProperty(this.value) && (this.localChecked = val[this.value])
32       },
33       deep: true
34     }
35   },
36   render () {
37     const { $slots, value } = this
38     const onChange = (checked) => {
39       this.$emit('change', { value, checked })
40     }
41     return (<CheckableTag key={value} vModel={this.localChecked} onChange={onChange}>
42       {$slots.default}
43     </CheckableTag>)
44   }
45 }