Merge branch '2.x' into dev
This commit is contained in:
+9
-8
@@ -133,11 +133,12 @@ export default {
|
||||
|
||||
### Events
|
||||
|
||||
| Event | Description | Arguments |
|
||||
| ------------- | ------------------------------- | -------------- |
|
||||
| click | Emitted when Popup is clicked | _event: Event_ |
|
||||
| open | Emitted when opening Popup | - |
|
||||
| close | Emitted when closing Popup | - |
|
||||
| opened | Emitted when Popup is opened | - |
|
||||
| closed | Emitted when Popup is closed | - |
|
||||
| click-overlay | Emitted when overlay is clicked | - |
|
||||
| Event | Description | Arguments |
|
||||
| --- | --- | --- |
|
||||
| click | Emitted when Popup is clicked | _event: Event_ |
|
||||
| click-overlay | Emitted when overlay is clicked | - |
|
||||
| click-close-icon `v2.11.0` | Emitted when close icon is clicked | _event: Event_ |
|
||||
| open | Emitted when opening Popup | - |
|
||||
| close | Emitted when closing Popup | - |
|
||||
| opened | Emitted when Popup is opened | - |
|
||||
| closed | Emitted when Popup is closed | - |
|
||||
|
||||
@@ -143,11 +143,12 @@ export default {
|
||||
|
||||
### Events
|
||||
|
||||
| 事件名 | 说明 | 回调参数 |
|
||||
| ------------- | -------------------------- | -------------- |
|
||||
| click | 点击弹出层时触发 | _event: Event_ |
|
||||
| open | 打开弹出层时触发 | - |
|
||||
| close | 关闭弹出层时触发 | - |
|
||||
| opened | 打开弹出层且动画结束后触发 | - |
|
||||
| closed | 关闭弹出层且动画结束后触发 | - |
|
||||
| click-overlay | 点击遮罩层时触发 | - |
|
||||
| 事件名 | 说明 | 回调参数 |
|
||||
| -------------------------- | -------------------------- | -------------- |
|
||||
| click | 点击弹出层时触发 | _event: Event_ |
|
||||
| click-overlay | 点击遮罩层时触发 | - |
|
||||
| click-close-icon `v2.11.0` | 点击关闭图标时触发 | _event: Event_ |
|
||||
| open | 打开弹出层时触发 | - |
|
||||
| close | 关闭弹出层时触发 | - |
|
||||
| opened | 打开弹出层且动画结束后触发 | - |
|
||||
| closed | 关闭弹出层且动画结束后触发 | - |
|
||||
|
||||
+7
-1
@@ -102,6 +102,7 @@ export default createComponent({
|
||||
'closed',
|
||||
'update:show',
|
||||
'click-overlay',
|
||||
'click-close-icon',
|
||||
],
|
||||
|
||||
setup(props, { emit, attrs, slots }) {
|
||||
@@ -173,6 +174,11 @@ export default createComponent({
|
||||
}
|
||||
};
|
||||
|
||||
const onClickCloseIcon = (event) => {
|
||||
emit('click-close-icon', event);
|
||||
close();
|
||||
};
|
||||
|
||||
const renderCloseIcon = () => {
|
||||
if (props.closeable) {
|
||||
return (
|
||||
@@ -181,7 +187,7 @@ export default createComponent({
|
||||
tabindex="0"
|
||||
name={props.closeIcon}
|
||||
class={bem('close-icon', props.closeIconPosition)}
|
||||
onClick={close}
|
||||
onClick={onClickCloseIcon}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -252,6 +252,18 @@ test('closeable prop', () => {
|
||||
expect(wrapper.emitted('input')[0][0]).toEqual(false);
|
||||
});
|
||||
|
||||
test('should emit click-close-icon event when close icon is clicked', () => {
|
||||
const wrapper = mount(Popup, {
|
||||
propsData: {
|
||||
value: true,
|
||||
closeable: true,
|
||||
},
|
||||
});
|
||||
|
||||
wrapper.find('.van-popup__close-icon').trigger('click');
|
||||
expect(wrapper.emitted('click-close-icon').length).toEqual(1);
|
||||
});
|
||||
|
||||
test('close-icon prop', () => {
|
||||
const wrapper = mount(Popup, {
|
||||
props: {
|
||||
|
||||
Reference in New Issue
Block a user