Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImagePreview组件 Close 方法执行两遍 #5338

Closed
anjina opened this issue Dec 20, 2019 · 7 comments
Closed

ImagePreview组件 Close 方法执行两遍 #5338

anjina opened this issue Dec 20, 2019 · 7 comments
Labels
Milestone

Comments

@anjina
Copy link

anjina commented Dec 20, 2019

你好,我把ImagePreview组件单独放在一个页面里, 图片预览时跳转至该页面, 触发close方法时,
onClose() {
console.log(this.$router);
this.$router.back();
}
代码如上,发现路由返回了上上个页面,调试的时候发现console执行了两次,我只点了一下,请问可能是什么原因呢?

@chenjiahan
Copy link
Member

可能是多次调用 ImagePreview 导致的,下个版本会兼容下

@chenjiahan
Copy link
Member

已在 2.3.2 版本修复

@anjina
Copy link
Author

anjina commented Dec 21, 2019

已在 2.3.2 版本修复

你好,安装了2.3.3的版本,貌似还是有这个问题呢。
image
close方法如上,
打印结果:
image

有一个和官网描述参数一样,有一个无参数,麻烦分析下 ,谢谢

@chenjiahan
Copy link
Member

看起来没什么问题,能否提供下复现的 codesandbox 链接呢

@Zclhlmgqzc
Copy link

Zclhlmgqzc commented Dec 27, 2019

@chenjiahan
应该是异步关闭的问题

this.$emit('close', {
  index,
   url: this.images[index]
});

if (!this.asyncClose) {
  this.$emit('input', false);
 }

异步关闭不应该执行 this.$emit('close')

if (!this.asyncClose) {
  this.$emit('close', {
    index,
    url: this.images[index]
  });

  this.$emit('input', false);
 }

@chenjiahan
Copy link
Member

@Zclhlmgqzc 这里确实有问题,下个版本会修复下

@chenjiahan
Copy link
Member

已在 2.4.0-beta.0 版本修复

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants