diff --git a/src/dialog/Dialog.js b/src/dialog/Dialog.js
index 490822474..323697bbf 100644
--- a/src/dialog/Dialog.js
+++ b/src/dialog/Dialog.js
@@ -78,16 +78,17 @@ export default createComponent({
return;
}
- const { title, message, messageAlign } = this;
- const children = this.slots();
+ const { message, messageAlign } = this;
+ const messageSlot = this.slots();
+ const title = this.slots('title') || this.title;
const Title = title && (
-
+
);
- const Content = (children || message) && (
+ const Content = (messageSlot || message) && (
- {children || (
+ {messageSlot || (
{Title}
diff --git a/src/dialog/README.md b/src/dialog/README.md
index f92ac7bc2..a7c2de5c1 100644
--- a/src/dialog/README.md
+++ b/src/dialog/README.md
@@ -160,3 +160,10 @@ export default {
|------|------|------|
| confirm | Triggered when click confirm button | - |
| cancel | Triggered when click cancel button | - |
+
+### Slots
+
+| Name | Description |
+|------|------|
+| default | Custom message |
+| title | Custom title |
diff --git a/src/dialog/README.zh-CN.md b/src/dialog/README.zh-CN.md
index 127894a91..4af4676aa 100644
--- a/src/dialog/README.zh-CN.md
+++ b/src/dialog/README.zh-CN.md
@@ -193,3 +193,12 @@ export default {
|------|------|------|
| confirm | 点击确认按钮时触发 | - |
| cancel | 点击取消按钮时触发 | - |
+
+### Slots
+
+通过组件调用 `Dialog` 时,支持以下插槽:
+
+| 名称 | 说明 |
+|------|------|
+| default | 自定义内容 |
+| title | 自定义标题 |
diff --git a/src/dialog/test/__snapshots__/index.spec.js.snap b/src/dialog/test/__snapshots__/index.spec.js.snap
index ff58c9d98..100a324a3 100644
--- a/src/dialog/test/__snapshots__/index.spec.js.snap
+++ b/src/dialog/test/__snapshots__/index.spec.js.snap
@@ -11,3 +11,17 @@ exports[`button text 1`] = `
`;
+
+exports[`default slot 1`] = `
+
+`;
+
+exports[`title slot 1`] = `
+
+
+
+
+`;
diff --git a/src/dialog/test/index.spec.js b/src/dialog/test/index.spec.js
index 8ad8d3a7a..509294545 100644
--- a/src/dialog/test/index.spec.js
+++ b/src/dialog/test/index.spec.js
@@ -102,3 +102,27 @@ test('button text', () => {
test('dialog component', () => {
expect(Dialog.Component).toEqual(DialogVue);
});
+
+test('default slot', () => {
+ const wrapper = mount(DialogVue, {
+ propsData: {
+ value: true
+ },
+ scopedSlots: {
+ default: () => 'Custom Message'
+ }
+ });
+ expect(wrapper).toMatchSnapshot();
+});
+
+test('title slot', () => {
+ const wrapper = mount(DialogVue, {
+ propsData: {
+ value: true
+ },
+ scopedSlots: {
+ title: () => 'Custom Title'
+ }
+ });
+ expect(wrapper).toMatchSnapshot();
+});