diff --git a/packages/devui-vue/devui/radio/__tests__/radio-group.spec.ts b/packages/devui-vue/devui/radio/__tests__/radio-group.spec.ts index c28a920c2a358187d49cb1c3bdc0d2b843bb0bab..5631096845c39f385e0e61f81757c84f02f5ce94 100644 --- a/packages/devui-vue/devui/radio/__tests__/radio-group.spec.ts +++ b/packages/devui-vue/devui/radio/__tests__/radio-group.spec.ts @@ -41,7 +41,7 @@ describe('RadioGroup', () => { expect(onChange).toHaveBeenCalledTimes(1); }); - it('radioGroup cssStyle work', async () => { + it('radioGroup direction work', async () => { const wrapper = mount(DRadioGroup, { props: { value: 'Item1' @@ -51,7 +51,7 @@ describe('RadioGroup', () => { await wrapper.setProps({ value: 'Item1', - cssStyle: 'row' + direction: 'row' }); expect(wrapper.html()).toMatch('is-row'); }); diff --git a/packages/devui-vue/devui/radio/src/radio-group.tsx b/packages/devui-vue/devui/radio/src/radio-group.tsx index f636bd062f2e6379421f45675e10e6d753f7cb17..b851a190100571dbe33c909359ef9fe5ea361543 100644 --- a/packages/devui-vue/devui/radio/src/radio-group.tsx +++ b/packages/devui-vue/devui/radio/src/radio-group.tsx @@ -1,7 +1,7 @@ -import { defineComponent, provide, toRef, ExtractPropTypes } from 'vue'; +import { defineComponent, provide, toRef, ExtractPropTypes } from 'vue' import DRadio from './radio' -import { radioGroupProps, radioGroupInjectionKey } from './radio-types'; -import './radio-group.scss'; +import { radioGroupProps, radioGroupInjectionKey } from './radio-types' +import './radio-group.scss' export default defineComponent({ name: 'DRadioGroup', @@ -10,9 +10,9 @@ export default defineComponent({ setup(props: ExtractPropTypes, { emit }) { /** change 事件 */ const emitChange = (radioValue: string) => { - emit('update:modelValue', radioValue); - emit('change', radioValue); - }; + emit('update:modelValue', radioValue) + emit('change', radioValue) + } // 注入给子组件 provide(radioGroupInjectionKey, { @@ -21,23 +21,20 @@ export default defineComponent({ disabled: toRef(props, 'disabled'), beforeChange: props.beforeChange, emitChange - }); + }) }, render() { - const { - cssStyle, - values - } = this; + const { values, direction } = this /** 获取展示内容 */ const getContent = () => { - const defaultSlot = this.$slots.default; + const defaultSlot = this.$slots.default // 有默认插槽则使用默认插槽 if (defaultSlot) { return defaultSlot() } // 有数据列表则使用数据列表 else if (Array.isArray(values)) { - return values.map(item => { + return values.map((item) => { return ( {item} @@ -52,15 +49,17 @@ export default defineComponent({ } return ( -
+
{getContent()}
- ); + ) } -}); +}) diff --git a/packages/devui-vue/devui/radio/src/radio-types.ts b/packages/devui-vue/devui/radio/src/radio-types.ts index f4aa59b76f34865db9b36dd387fd1e9ec0bf81d4..8448f86e9e2bd8ee5f21bbfe5228b628389f3314 100644 --- a/packages/devui-vue/devui/radio/src/radio-types.ts +++ b/packages/devui-vue/devui/radio/src/radio-types.ts @@ -44,7 +44,7 @@ export const radioGroupProps = { default: null, }, /** 展示方式,横向/竖向 */ - cssStyle: { + direction: { type: String as PropType<'row' | 'column'>, default: 'column', }, diff --git a/packages/devui-vue/docs/components/dropdown/index.md b/packages/devui-vue/docs/components/dropdown/index.md index 296eb3ee9c948040a184e641372a527be92fefe3..061c602400894cb9ab570254cb4b88d7874f2a98 100644 --- a/packages/devui-vue/docs/components/dropdown/index.md +++ b/packages/devui-vue/docs/components/dropdown/index.md @@ -14,7 +14,7 @@