mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
feat(Toast): add overlayStyle option #7898
This commit is contained in:
parent
3b007c9cfd
commit
c553551578
@ -168,9 +168,9 @@ export default createComponent({
|
|||||||
<Overlay
|
<Overlay
|
||||||
show={props.show}
|
show={props.show}
|
||||||
class={props.overlayClass}
|
class={props.overlayClass}
|
||||||
style={props.overlayStyle}
|
|
||||||
zIndex={zIndex.value}
|
zIndex={zIndex.value}
|
||||||
duration={props.duration}
|
duration={props.duration}
|
||||||
|
customStyle={props.overlayStyle}
|
||||||
onClick={onClickOverlay}
|
onClick={onClickOverlay}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
@ -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_ | - |
|
||||||
|
| 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_ | - |
|
||||||
| transition | Transition, equivalent to `name` prop of [transtion](https://v3.vuejs.org/api/built-in-components.html#transition) | _string_ | `van-fade` |
|
| transition | Transition, equivalent to `name` prop of [transtion](https://v3.vuejs.org/api/built-in-components.html#transition) | _string_ | `van-fade` |
|
||||||
|
@ -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_ | - |
|
||||||
|
| overlayStyle `v3.0.4` | 自定义遮罩层样式 | _object_ | - |
|
||||||
| onOpened | 完全展示后的回调函数 | _Function_ | - |
|
| onOpened | 完全展示后的回调函数 | _Function_ | - |
|
||||||
| onClose | 关闭时的回调函数 | _Function_ | - |
|
| onClose | 关闭时的回调函数 | _Function_ | - |
|
||||||
| transition | 动画类名,等价于 [transtion](https://v3.cn.vuejs.org/api/built-in-components.html#transition) 的`name`属性 | _string_ | `van-fade` |
|
| transition | 动画类名,等价于 [transtion](https://v3.cn.vuejs.org/api/built-in-components.html#transition) 的`name`属性 | _string_ | `van-fade` |
|
||||||
|
@ -22,6 +22,7 @@ export default createComponent({
|
|||||||
lockScroll: Boolean,
|
lockScroll: Boolean,
|
||||||
loadingType: String,
|
loadingType: String,
|
||||||
forbidClick: Boolean,
|
forbidClick: Boolean,
|
||||||
|
overlayStyle: Object,
|
||||||
closeOnClick: Boolean,
|
closeOnClick: Boolean,
|
||||||
type: {
|
type: {
|
||||||
type: String,
|
type: String,
|
||||||
@ -115,6 +116,7 @@ export default createComponent({
|
|||||||
]}
|
]}
|
||||||
lockScroll={false}
|
lockScroll={false}
|
||||||
transition={props.transition}
|
transition={props.transition}
|
||||||
|
overlayStyle={props.overlayStyle}
|
||||||
onClick={onClick}
|
onClick={onClick}
|
||||||
onClosed={clearTimer}
|
onClosed={clearTimer}
|
||||||
>
|
>
|
||||||
|
17
src/toast/test/index.spec.js
Normal file
17
src/toast/test/index.spec.js
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
import Toast from '../Toast';
|
||||||
|
import { mount } from '@vue/test-utils';
|
||||||
|
import { later } from '../../../test';
|
||||||
|
|
||||||
|
test('should change overlay style after using overlay-style prop', async () => {
|
||||||
|
const wrapper = mount(Toast, {
|
||||||
|
props: {
|
||||||
|
show: true,
|
||||||
|
overlayStyle: {
|
||||||
|
background: 'red',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
await later();
|
||||||
|
expect(wrapper.find('.van-overlay').element.style.background).toEqual('red');
|
||||||
|
});
|
1
types/toast.d.ts
vendored
1
types/toast.d.ts
vendored
@ -22,6 +22,7 @@ export type ToastOptions = {
|
|||||||
loadingType?: ToastLoadingType;
|
loadingType?: ToastLoadingType;
|
||||||
forbidClick?: boolean;
|
forbidClick?: boolean;
|
||||||
closeOnClick?: boolean;
|
closeOnClick?: boolean;
|
||||||
|
overlayStyle?: Record<string, any>;
|
||||||
closeOnClickOverlay?: boolean;
|
closeOnClickOverlay?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user