[new feature] Dialog: add close-on-popstate prop (#3709)

This commit is contained in:
neverland 2019-07-01 17:00:33 +08:00 committed by GitHub
parent 2df51f5aef
commit e4ce6137bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 5 additions and 1 deletions

View File

@ -1,11 +1,12 @@
import { createNamespace } from '../utils';
import { PopupMixin } from '../mixins/popup';
import { CloseOnPopstateMixin } from '../mixins/close-on-popstate';
import Button from '../button';
const [createComponent, bem, t] = createNamespace('dialog');
export default createComponent({
mixins: [PopupMixin],
mixins: [PopupMixin, CloseOnPopstateMixin],
props: {
title: String,

View File

@ -128,6 +128,7 @@ export default {
| confirmButtonText | Confirm button text | `String` | `Confirm` |
| confirmButtonColor | Confirm button color | `String` | `#1989fa` |
| overlay | Whether to show overlay | `Boolean` | `true` |
| closeOnPopstate | Whether to close when popstate | `Boolean` | `false` |
| closeOnClickOverlay | Whether to close when click overlay | `Boolean` | `false` |
| lockScroll | Whether to lock body scroll | `Boolean` | `true` |
| beforeClose | Callback before close,<br>call done() to close dialog,<br>call done(false) to cancel loading | (action: string, done: function) => void | - |

View File

@ -157,6 +157,7 @@ export default {
| confirmButtonText | 确认按钮文案 | `String` | `确认` | - |
| confirmButtonColor | 确认按钮颜色 | `String` | `#1989fa` | 1.6.14 |
| overlay | 是否展示遮罩层 | `Boolean` | `true` | - |
| closeOnPopstate | 是否在页面回退时自动关闭 | `Boolean` | `false` | 2.0.5 |
| closeOnClickOverlay | 点击遮罩层时是否关闭弹窗 | `Boolean` | `false` | - |
| lockScroll | 是否锁定背景滚动 | `Boolean` | `true` | - |
| beforeClose | 关闭前的回调函数,<br>调用 done() 后关闭弹窗,<br>调用 done(false) 阻止弹窗关闭 | `(action, done) => void` | - | - |

View File

@ -60,6 +60,7 @@ Dialog.defaultOptions = {
confirmButtonColor: null,
showConfirmButton: true,
showCancelButton: false,
closeOnPopstate: false,
closeOnClickOverlay: false,
callback: action => {
instance[action === 'confirm' ? 'resolve' : 'reject'](action);