diff --git a/src/action-sheet/README.md b/src/action-sheet/README.md index 51530f2c5..6b363d8b7 100644 --- a/src/action-sheet/README.md +++ b/src/action-sheet/README.md @@ -190,3 +190,10 @@ export default { | opened | Triggered when opened ActionSheet | - | | closed | Triggered when closed ActionSheet | - | | click-overlay | Triggered when click overlay | - | + +### Slots + +| Name | Description | +| --------------------- | ------------------ | +| default | Custom content | +| description `v2.10.4` | Custom description | diff --git a/src/action-sheet/README.zh-CN.md b/src/action-sheet/README.zh-CN.md index c18f9672b..e233fcc41 100644 --- a/src/action-sheet/README.zh-CN.md +++ b/src/action-sheet/README.zh-CN.md @@ -199,6 +199,13 @@ export default { | closed | 关闭面板且动画结束后触发 | - | | click-overlay | 点击遮罩层时触发 | - | +### Slots + +| 名称 | 说明 | +| --------------------- | -------------------- | +| default | 自定义面板的展示内容 | +| description `v2.10.4` | 自定义描述文案 | + ## 常见问题 ### 引入时提示 dependencies not found? diff --git a/src/action-sheet/index.js b/src/action-sheet/index.js index 2e15c72f1..b859dfb3f 100644 --- a/src/action-sheet/index.js +++ b/src/action-sheet/index.js @@ -102,40 +102,37 @@ export default createComponent({ ); }; + const renderDescription = () => { + if (props.description || slots.description) { + const content = slots.description + ? slots.description() + : props.description; + return
{content}
; + } + }; + const renderOptions = () => { if (props.actions) { return props.actions.map(renderOption); } }; - return () => { - const { round, description } = props; - - const Content = slots.default && ( -
{slots.default()}
- ); - - const Description = description && ( -
{description}
- ); - - return ( - - {renderHeader()} - {Description} - {renderOptions()} - {Content} - {renderCancel()} - - ); - }; + return () => ( + + {renderHeader()} + {renderDescription()} + {renderOptions()} + {slots.default &&
{slots.default()}
} + {renderCancel()} +
+ ); }, }); diff --git a/src/action-sheet/test/__snapshots__/index.spec.js.snap b/src/action-sheet/test/__snapshots__/index.spec.js.snap index d1bb01fd6..e27c3187b 100644 --- a/src/action-sheet/test/__snapshots__/index.spec.js.snap +++ b/src/action-sheet/test/__snapshots__/index.spec.js.snap @@ -24,6 +24,12 @@ exports[`description prop 1`] = ` `; +exports[`description slot 1`] = ` +
+
Custom Description
+
+`; + exports[`disable lazy-render 1`] = `