feat(Toast): add overlayClass option (#7925)

This commit is contained in:
neverland 2021-01-16 19:42:06 +08:00 committed by GitHub
parent e43ec34964
commit f8fb4fa96d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 6 additions and 0 deletions

View File

@ -161,6 +161,7 @@ Toast.resetDefaultOptions('loading');
| loadingType | Loading icon type, can be set to `spinner` | _string_ | `circular` | | loadingType | Loading icon type, can be set to `spinner` | _string_ | `circular` |
| duration | Toast duration(ms), won't disappear if value is 0 | _number_ | `2000` | | duration | Toast duration(ms), won't disappear if value is 0 | _number_ | `2000` |
| className | Custom className | _any_ | - | | className | Custom className | _any_ | - |
| overlayClass `v3.0.4` | Custom overlay class | _string \| string[] \| object_ | - |
| overlayStyle `v3.0.4` | Custom overlay style | _object_ | - | | overlayStyle `v3.0.4` | Custom overlay style | _object_ | - |
| onOpened | Callback function after opened | _Function_ | - | | onOpened | Callback function after opened | _Function_ | - |
| onClose | Callback function after close | _Function_ | - | | onClose | Callback function after close | _Function_ | - |

View File

@ -174,6 +174,7 @@ Toast.resetDefaultOptions('loading');
| loadingType | [加载图标类型](#/zh-CN/loading), 可选值为 `spinner` | _string_ | `circular` | | loadingType | [加载图标类型](#/zh-CN/loading), 可选值为 `spinner` | _string_ | `circular` |
| duration | 展示时长(ms),值为 0 时toast 不会消失 | _number_ | `2000` | | duration | 展示时长(ms),值为 0 时toast 不会消失 | _number_ | `2000` |
| className | 自定义类名 | _any_ | - | | className | 自定义类名 | _any_ | - |
| overlayClass `v3.0.4` | 自定义遮罩层类名 | _string \| string[] \| object_ | - |
| overlayStyle `v3.0.4` | 自定义遮罩层样式 | _object_ | - | | overlayStyle `v3.0.4` | 自定义遮罩层样式 | _object_ | - |
| onOpened | 完全展示后的回调函数 | _Function_ | - | | onOpened | 完全展示后的回调函数 | _Function_ | - |
| onClose | 关闭时的回调函数 | _Function_ | - | | onClose | 关闭时的回调函数 | _Function_ | - |

View File

@ -22,6 +22,7 @@ export default createComponent({
lockScroll: Boolean, lockScroll: Boolean,
loadingType: String, loadingType: String,
forbidClick: Boolean, forbidClick: Boolean,
overlayClass: null,
overlayStyle: Object, overlayStyle: Object,
closeOnClick: Boolean, closeOnClick: Boolean,
type: { type: {
@ -116,6 +117,7 @@ export default createComponent({
]} ]}
lockScroll={false} lockScroll={false}
transition={props.transition} transition={props.transition}
overlayClass={props.overlayClass}
overlayStyle={props.overlayStyle} overlayStyle={props.overlayStyle}
onClick={onClick} onClick={onClick}
onClosed={clearTimer} onClosed={clearTimer}

View File

@ -18,6 +18,7 @@ const defaultOptions = {
transition: 'van-fade', transition: 'van-fade',
forbidClick: false, forbidClick: false,
loadingType: undefined, loadingType: undefined,
overlayClass: '',
overlayStyle: null, overlayStyle: null,
closeOnClick: false, closeOnClick: false,
closeOnClickOverlay: false, closeOnClickOverlay: false,

1
types/toast.d.ts vendored
View File

@ -22,6 +22,7 @@ export type ToastOptions = {
loadingType?: ToastLoadingType; loadingType?: ToastLoadingType;
forbidClick?: boolean; forbidClick?: boolean;
closeOnClick?: boolean; closeOnClick?: boolean;
overlayClass?: any;
overlayStyle?: Record<string, any>; overlayStyle?: Record<string, any>;
closeOnClickOverlay?: boolean; closeOnClickOverlay?: boolean;
}; };