You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ant-design-vue/components/tag/CheckableTag.jsx

44 lines
1.0 KiB

import PropTypes from '../_util/vue-types';
import { ConfigConsumerProps } from '../config-provider';
7 years ago
export default {
name: 'ACheckableTag',
7 years ago
model: {
prop: 'checked',
},
props: {
prefixCls: PropTypes.string,
7 years ago
checked: Boolean,
},
inject: {
configProvider: { default: () => ConfigConsumerProps },
},
7 years ago
computed: {
classes() {
const { checked, prefixCls: customizePrefixCls } = this;
const getPrefixCls = this.configProvider.getPrefixCls;
const prefixCls = getPrefixCls('tag', customizePrefixCls);
7 years ago
return {
[`${prefixCls}`]: true,
[`${prefixCls}-checkable`]: true,
[`${prefixCls}-checkable-checked`]: checked,
};
7 years ago
},
},
methods: {
handleClick() {
const { checked } = this;
this.$emit('input', !checked);
this.$emit('change', !checked);
7 years ago
},
},
render() {
const { classes, handleClick, $slots } = this;
return (
<div class={classes} onClick={handleClick}>
{$slots.default}
</div>
);
},
};