diff --git a/packages/radio-button/RadioButton.vue b/packages/radio-button/RadioButton.vue index 69cde713a..80d9ed640 100644 --- a/packages/radio-button/RadioButton.vue +++ b/packages/radio-button/RadioButton.vue @@ -90,7 +90,7 @@ export default { } function useInject() { - const elForm = inject('elFrom', {}) + const elForm = inject('elForm', {}) const elFormItem = inject('elFormItem', {}) return { elForm, @@ -139,11 +139,10 @@ function useModel({ radioGroup }) { function useStyle({ radioGroup, disabled, value, label, elForm, elFormItem }) { const { ctx } = getCurrentInstance() - const elFormDisable = (elForm.props || {}).disabled - const elFormItemSize = (elFormItem.ctx || {}).elFormItemSize + const elFormDisable = elForm.disabled const size = computed(() => { - const temRadioSize = elFormItemSize || (ctx.$ELEMENT || {}).size + const temRadioSize = elFormItem.elFormItemSize || (ctx.$ELEMENT || {}).size return radioGroup.ctx.radioGroupSize || temRadioSize }) const isDisabled = computed(() => { diff --git a/packages/radio-group/RadioGroup.vue b/packages/radio-group/RadioGroup.vue index d52a10408..568adb03b 100644 --- a/packages/radio-group/RadioGroup.vue +++ b/packages/radio-group/RadioGroup.vue @@ -43,8 +43,7 @@ export default { setup(props) { const { modelValue = {}, size = {} } = toRefs(props) const { dispatch } = useEmitter() - - const elFormItem = inject('elFormItem', { ctx: {} }) + const { elFormItem } = useInject() watch(modelValue, (v) => { dispatch('el.form.change', v) @@ -62,6 +61,13 @@ export default { } } +function useInject() { + const elFormItem = inject('elFormItem', {}) + return { + elFormItem + } +} + function useKeyDown() { const { ctx } = getCurrentInstance() onMounted(() => { @@ -117,9 +123,7 @@ function useStyle({ elFormItem, size }) { const { ctx, vnode } = getCurrentInstance() const radioGroupSize = computed(() => { - return ( - size.value || elFormItem.ctx.elFormItemSize || (ctx.$ELEMENT || {}).size - ) + return size.value || elFormItem.elFormItemSize || (ctx.$ELEMENT || {}).size }) const elTag = computed(() => { diff --git a/packages/radio/Radio.vue b/packages/radio/Radio.vue index 57c62c7bf..f615c883c 100644 --- a/packages/radio/Radio.vue +++ b/packages/radio/Radio.vue @@ -110,7 +110,7 @@ export default { } function useInject() { - const elForm = inject('elFrom', {}) + const elForm = inject('elForm', {}) const elFormItem = inject('elFormItem', {}) return { elForm, @@ -173,11 +173,10 @@ function useStyle({ elFormItem }) { const { ctx } = getCurrentInstance() - const elFormDisable = (elForm.props || {}).disabled - const elFormItemSize = (elFormItem.ctx || {}).elFormItemSize + const elFormDisable = elForm.disabled const radioSize = computed(() => { const temRadioSize = - unref(size) || elFormItemSize || (ctx.$ELEMENT || {}).size + unref(size) || elFormItem.elFormItemSize || (ctx.$ELEMENT || {}).size return isGroup ? radioGroup.ctx.radioGroupSize || temRadioSize : temRadioSize