mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
[new feature] Popup: add open/close event (#2649)
This commit is contained in:
parent
079b582460
commit
466bb3ce1e
@ -48,8 +48,10 @@ export default {
|
||||
|
||||
watch: {
|
||||
value(val) {
|
||||
const type = val ? 'open' : 'close';
|
||||
this.inited = this.inited || this.value;
|
||||
this[val ? 'open' : 'close']();
|
||||
this[type]();
|
||||
this.$emit(type);
|
||||
},
|
||||
|
||||
getContainer() {
|
||||
|
@ -54,4 +54,6 @@ Use `position` prop to set popup display position
|
||||
|
||||
| Event | Description | Arguments |
|
||||
|------|------|------|
|
||||
| open | Triggered when open Popup | - |
|
||||
| close | Triggered when close Popup | - |
|
||||
| click-overlay | Triggered when click overlay | - |
|
||||
|
@ -141,3 +141,11 @@ test('close on click modal', () => {
|
||||
modal.click();
|
||||
expect(wrapper.vm.value).toBeFalsy();
|
||||
});
|
||||
|
||||
test('oepn & close event', () => {
|
||||
wrapper = mount(Popup);
|
||||
wrapper.vm.value = true;
|
||||
expect(wrapper.emitted('open')).toBeTruthy();
|
||||
wrapper.vm.value = false;
|
||||
expect(wrapper.emitted('close')).toBeTruthy();
|
||||
});
|
||||
|
@ -54,4 +54,6 @@ export default {
|
||||
|
||||
| 事件名 | 说明 | 参数 |
|
||||
|------|------|------|
|
||||
| open | 打开弹出层时触发 | - |
|
||||
| close | 关闭弹出层时触发 | - |
|
||||
| click-overlay | 点击蒙层时触发 | - |
|
||||
|
Loading…
x
Reference in New Issue
Block a user