mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
feat(ShareSheet): add click-overlay event (#6765)
This commit is contained in:
parent
3748ab646c
commit
1d56e97ce3
@ -137,6 +137,7 @@ export default {
|
|||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| select | Triggered when click option | _option: Option, index: number_ |
|
| select | Triggered when click option | _option: Option, index: number_ |
|
||||||
| cancel | Triggered when click cancel button | - |
|
| cancel | Triggered when click cancel button | - |
|
||||||
|
| click-overlay `v2.9.1` | Triggered when click overlay | - |
|
||||||
|
|
||||||
### Slots
|
### Slots
|
||||||
|
|
||||||
|
@ -181,10 +181,11 @@ export default {
|
|||||||
|
|
||||||
### Events
|
### Events
|
||||||
|
|
||||||
| 事件名 | 说明 | 回调参数 |
|
| 事件名 | 说明 | 回调参数 |
|
||||||
| ------ | ------------------ | ------------------------------- |
|
| --- | --- | --- |
|
||||||
| select | 点击分享选项时触发 | _option: Option, index: number_ |
|
| select | 点击分享选项时触发 | _option: Option, index: number_ |
|
||||||
| cancel | 点击取消按钮时触发 | - |
|
| cancel | 点击取消按钮时触发 | - |
|
||||||
|
| click-overlay `v2.9.1` | 点击遮罩层时触发 | - |
|
||||||
|
|
||||||
### Slots
|
### Slots
|
||||||
|
|
||||||
|
@ -122,6 +122,10 @@ export default createComponent({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
onClickOverlay() {
|
||||||
|
this.$emit('click-overlay');
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
@ -140,6 +144,7 @@ export default createComponent({
|
|||||||
closeOnClickOverlay={this.closeOnClickOverlay}
|
closeOnClickOverlay={this.closeOnClickOverlay}
|
||||||
safeAreaInsetBottom={this.safeAreaInsetBottom}
|
safeAreaInsetBottom={this.safeAreaInsetBottom}
|
||||||
onInput={this.toggle}
|
onInput={this.toggle}
|
||||||
|
onClick-overlay={this.onClickOverlay}
|
||||||
>
|
>
|
||||||
{this.genHeader()}
|
{this.genHeader()}
|
||||||
{this.genRows()}
|
{this.genRows()}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import ShareSheet from '..';
|
import ShareSheet from '..';
|
||||||
import { mount } from '../../../test';
|
import { mount, trigger, later } from '../../../test';
|
||||||
|
|
||||||
test('cancel-text prop', () => {
|
test('cancel-text prop', () => {
|
||||||
const wrapper = mount(ShareSheet, {
|
const wrapper = mount(ShareSheet, {
|
||||||
@ -70,3 +70,19 @@ test('title & description slot', () => {
|
|||||||
|
|
||||||
expect(wrapper).toMatchSnapshot();
|
expect(wrapper).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('click-overlay event', async () => {
|
||||||
|
const root = document.createElement('div');
|
||||||
|
const wrapper = mount(ShareSheet, {
|
||||||
|
propsData: {
|
||||||
|
value: true,
|
||||||
|
getContainer: () => root,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
await later();
|
||||||
|
|
||||||
|
const overlay = root.querySelector('.van-overlay');
|
||||||
|
trigger(overlay, 'click');
|
||||||
|
expect(wrapper.emitted('click-overlay')).toBeTruthy();
|
||||||
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user