diff --git a/components/drawer/drawer.tsx b/components/drawer/drawer.tsx index 5dda9df8..161d4be5 100644 --- a/components/drawer/drawer.tsx +++ b/components/drawer/drawer.tsx @@ -162,12 +162,24 @@ const Drawer = defineComponent({ props.displayDirective === 'show', ); + const wrapperClass = computed(() => { + return [`${prefixCls}-wrapper`, props.contentClass].filter(Boolean); + }); + + const rootClass = computed(() => { + return [ + prefixCls, + `${prefixCls}-${props.placement}`, + props.wrapperClass, + ].filter(Boolean); + }); + return () => ( -
+
{props.mask && showDom.value && (
event.stopPropagation()} diff --git a/components/drawer/props.ts b/components/drawer/props.ts index b003c7ed..b55fc4e8 100644 --- a/components/drawer/props.ts +++ b/components/drawer/props.ts @@ -77,7 +77,10 @@ export const drawerProps = { type: String as PropType, default: 'right' satisfies DrawerPlacement, }, + // 内容外层类名 contentClass: String, + // 根类名 + wrapperClass: String, resizable: { type: Boolean, default: false, diff --git a/components/modal/modal.tsx b/components/modal/modal.tsx index 54f41128..aad57559 100644 --- a/components/modal/modal.tsx +++ b/components/modal/modal.tsx @@ -210,12 +210,21 @@ const Modal = defineComponent({ mouseDownInsideChild.value = false; }; + // 最外层类名 + const rootClass = computed(() => { + return [prefixCls, props.wrapperClass].filter(Boolean); + }); + + const wrapperClass = computed(() => { + return [`${prefixCls}-wrapper`, props.contentClass].filter(Boolean); + }); + return () => ( -
+
{props.mask && showDom.value && (
handleClickMask(event)} >
event.stopPropagation()} onMousedown={() => { diff --git a/components/modal/props.ts b/components/modal/props.ts index a6bde7ac..b78ccdc4 100644 --- a/components/modal/props.ts +++ b/components/modal/props.ts @@ -85,7 +85,10 @@ export const modalProps = { type: Boolean, default: false, }, + // 内容外层类名 contentClass: String, + // 根类名 + wrapperClass: String, } as const satisfies ComponentObjectPropsOptions; export type ModalProps = ExtractPublicPropTypes; diff --git a/docs/.vitepress/components/drawer/index.md b/docs/.vitepress/components/drawer/index.md index 68b42032..cde940ac 100644 --- a/docs/.vitepress/components/drawer/index.md +++ b/docs/.vitepress/components/drawer/index.md @@ -85,7 +85,7 @@ closable.vue | maskClosable | 点击蒙层是否允许关闭 | boolean | `true` | | escClosable | 按下 ESC 是否允许关闭 | boolean | `true` | | operable | 仅 mask 为 false 时生效,不显示蒙层时,页面是否可交互 | boolean | `false` | -| title | 标题 | string | - | +| title | 标题 | string | `-` | | footer | 是否显示底部内容 | boolean | `false` | | footerBorder | 是否显示底部分割线 | boolean | `false` | | okText | 确认按钮文字 | string | 确定 | @@ -96,11 +96,12 @@ closable.vue | width | 宽度
(即将废弃,推荐使用 dimension) | string/number | 520 | | hight | 高度,在 placement 为 top 或 bottom 时使用
(即将废弃,推荐使用 dimension) | string/number | 520 | | placement | 抽屉方向 | `'right'` `'bottom'` `'left'` `'right'` | `'right'` | -| contentClass | 可用于设置内容的类名 | string | - | +| contentClass | 可用于设置内容的类名 | string | `-` | +| wrapperClass | 可用于设置组件根类名 | string | `-` | | getContainer | 指定 `Drawer` 挂载的 HTML 节点 | () => HTMLElement | `() => document.body` | | resizable | 是否支持宽度/高度可拖拽 | boolean | `false` | -| resizeMax | 可拖拽的最大尺寸(如:`100`、`'200px'`、`'30%'`) | number/string | - | -| resizeMin | 可拖拽的最小尺寸(同上) | number/string | - | +| resizeMax | 可拖拽的最大尺寸(如:`100`、`'200px'`、`'30%'`) | number/string | `-` | +| resizeMin | 可拖拽的最小尺寸(同上) | number/string | `-` | ## Drawer Event diff --git a/docs/.vitepress/components/modal/index.md b/docs/.vitepress/components/modal/index.md index b46eaa08..be8fe846 100644 --- a/docs/.vitepress/components/modal/index.md +++ b/docs/.vitepress/components/modal/index.md @@ -105,6 +105,7 @@ closable.vue | center | 标题、内容、按钮居中 | Boolean | `false` | | fullScreen | 全屏显示 | Boolean | `false` | | contentClass | 可用于设置内容的类名 | String | `-` | +| wrapperClass | 可用于设置组件根类名 | String | `-` | | getContainer | 指定 `Modal` 挂载的 HTML 节点 | () => HTMLElement | `() => document.body` | ## Modal Event