mirror of
https://gitee.com/ant-design-vue/ant-design-vue.git
synced 2024-12-01 11:38:36 +08:00
35 lines
1.1 KiB
Vue
35 lines
1.1 KiB
Vue
import { inject } from 'vue';
|
|
import Radio from './Radio';
|
|
import { getOptionProps, getSlot } from '../_util/props-util';
|
|
import { defaultConfigProvider } from '../config-provider';
|
|
|
|
export default {
|
|
name: 'ARadioButton',
|
|
props: {
|
|
...Radio.props,
|
|
},
|
|
setup() {
|
|
return {
|
|
configProvider: inject('configProvider', defaultConfigProvider),
|
|
radioGroupContext: inject('radioGroupContext', {}),
|
|
};
|
|
},
|
|
render() {
|
|
const props = getOptionProps(this);
|
|
const { prefixCls: customizePrefixCls, ...otherProps } = props;
|
|
const getPrefixCls = this.configProvider.getPrefixCls;
|
|
const prefixCls = getPrefixCls('radio-button', customizePrefixCls);
|
|
|
|
const radioProps = {
|
|
prefixCls,
|
|
...otherProps,
|
|
};
|
|
if (this.radioGroupContext) {
|
|
radioProps.onChange = this.radioGroupContext.onRadioChange;
|
|
radioProps.checked = props.value === this.radioGroupContext.stateValue;
|
|
radioProps.disabled = props.disabled || this.radioGroupContext.disabled;
|
|
}
|
|
return <Radio {...radioProps}>{getSlot(this)}</Radio>;
|
|
},
|
|
};
|