diff --git a/src/_common b/src/_common index d05666b73..8cf20889c 160000 --- a/src/_common +++ b/src/_common @@ -1 +1 @@ -Subproject commit d05666b7300e4d3f3e96e4063d6c6352c1b3f7c9 +Subproject commit 8cf20889c0d2ff21dc64db0523c747a432351f4a diff --git a/src/drawer/drawer.en-US.md b/src/drawer/drawer.en-US.md index 28871fcfd..42c700eab 100644 --- a/src/drawer/drawer.en-US.md +++ b/src/drawer/drawer.en-US.md @@ -43,6 +43,7 @@ destroyOnClose | Boolean | false | \- | N drawerClassName | String | - | \- | N footer | Boolean / Slot / Function | true | Typescript: `boolean \| TNode`. [see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N header | String / Boolean / Slot / Function | true | Typescript: `string \| boolean \| TNode`. [see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N +lazy | Boolean | false | Enable Drawer lazy loading, the contents of the Drawer are not rendered when enable | N mode | String | overlay | options: overlay/push | N placement | String | right | options: left/right/top/bottom | N preventScrollThrough | Boolean | true | \- | N diff --git a/src/drawer/drawer.md b/src/drawer/drawer.md index e3fa3b16c..99081de5c 100644 --- a/src/drawer/drawer.md +++ b/src/drawer/drawer.md @@ -43,6 +43,7 @@ destroyOnClose | Boolean | false | 抽屉关闭时是否销毁节点 | N drawerClassName | String | - | 抽屉元素类名。 | N footer | Boolean / Slot / Function | true | 底部操作栏,默认会有“确认”和“取消”两个按钮。值为 true 显示默认操作按钮,值为 false 或 null 不显示任何内容,值类型为 TNode 表示自定义底部内容。TS 类型:`boolean \| TNode`。[通用类型定义](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N header | String / Boolean / Slot / Function | true | 头部内容。值为 true 显示空白头部,值为 false 不显示头部,值类型为 string 则直接显示值,值类型为 TNode 表示自定义头部内容。TS 类型:`string \| boolean \| TNode`。[通用类型定义](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N +lazy | Boolean | false | 是否启用抽屉懒加载,启用时抽屉的内容不渲染 | N mode | String | overlay | 展开方式,有两种:直接展示在内容上方 和 推开内容区域。可选项:overlay/push | N placement | String | right | 抽屉方向。可选项:left/right/top/bottom | N preventScrollThrough | Boolean | true | 防止滚动穿透 | N diff --git a/src/drawer/drawer.tsx b/src/drawer/drawer.tsx index 320f60b3d..e926ae400 100644 --- a/src/drawer/drawer.tsx +++ b/src/drawer/drawer.tsx @@ -47,6 +47,7 @@ export default mixins( animationEnd: true, styleTimer: null, styleEl: null, + isMounted: false, }; }, computed: { @@ -136,6 +137,7 @@ export default mixins( visible: { handler(val) { if (val) { + this.isMounted = true; this.$nextTick(() => { (this.$refs.drawerContainer as HTMLDivElement)?.focus?.(); }); @@ -172,7 +174,7 @@ export default mixins( }, render() { - if (this.destroyOnClose && !this.visible && this.animationEnd) return null; + if ((this.destroyOnClose && !this.visible && this.animationEnd) || (!this.isMounted && this.lazy)) return null; const { CloseIcon } = this.useGlobalIcon({ CloseIcon: TdCloseIcon, diff --git a/src/drawer/props.ts b/src/drawer/props.ts index 0b6040f22..eab91db50 100644 --- a/src/drawer/props.ts +++ b/src/drawer/props.ts @@ -59,6 +59,8 @@ export default { type: [String, Boolean, Function] as PropType, default: true, }, + /** 是否启用抽屉懒加载,启用时抽屉的内容不渲染 */ + lazy: Boolean, /** 展开方式,有两种:直接展示在内容上方 和 推开内容区域 */ mode: { type: String as PropType, diff --git a/src/drawer/type.ts b/src/drawer/type.ts index 8ddc47dba..7c2894a9f 100644 --- a/src/drawer/type.ts +++ b/src/drawer/type.ts @@ -61,6 +61,11 @@ export interface TdDrawerProps { * @default true */ header?: string | boolean | TNode; + /** + * 是否启用抽屉懒加载,启用时抽屉的内容不渲染 + * @default false + */ + lazy?: boolean; /** * 展开方式,有两种:直接展示在内容上方 和 推开内容区域 * @default overlay