Skip to content

Commit

Permalink
feat(dialog): dialog header 支持 string 配置
Browse files Browse the repository at this point in the history
  • Loading branch information
olivewind committed Jul 20, 2018
1 parent ec9490c commit 6d4bd24
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
6 changes: 2 additions & 4 deletions examples/routers/dialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<div class="config-section">footer: <b>{{config.footer}}</b></div>
</div>
<div slot="content">
<button class="dao-btn blue" @click="config.visible = true">{{config.header.title}}</button>
<button class="dao-btn blue" @click="config.visible = true">{{config.header.title || config.header}}</button>
<dao-dialog
:visible.sync="config.visible"
@before-close="onBeforeClose"
Expand Down Expand Up @@ -222,9 +222,7 @@
configs: [
{
visible: false,
header: {
title: '最简单的默认版本',
},
header: '最简单的默认版本',
},
{
visible: false,
Expand Down
8 changes: 7 additions & 1 deletion src/components/dao-dialog/dao-dialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export default {
default: false,
},
header: {
type: [Object, Boolean],
type: [Object, Boolean, String],
default() {
return {};
},
Expand Down Expand Up @@ -101,6 +101,12 @@ export default {
// 兼容旧版 dialog
computedHeader() {
if (this.config.showHeader === false || this.header === false) return false;
if (typeof this.header === 'string') {
return {
title: this.header,
showClose: this.config.showHeaderClose,
};
}
return {
title: this.config.title || this.header.title,
showClose: this.config.showHeaderClose || this.header.showClose,
Expand Down

0 comments on commit 6d4bd24

Please sign in to comment.