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

Taro.previewIamge()H5环境下预览和返回问题 #8956

Closed
FLF1995 opened this issue Mar 23, 2021 · 4 comments
Closed

Taro.previewIamge()H5环境下预览和返回问题 #8956

FLF1995 opened this issue Mar 23, 2021 · 4 comments

Comments

@FLF1995
Copy link

FLF1995 commented Mar 23, 2021

问题描述
taro转换H5嵌入APP,调用Taro.previewImage后,点击返回,视图仍然是图片预览,但实际页面已经跳转
复现步骤

期望行为
图片预览关闭,而页面不会被回退。

报错信息
行为错误,无报错。

系统信息

Taro v1.2 及以上版本已添加 taro info 命令,方便大家查看系统及依赖信息,运行该命令后将结果贴下面即可。

操作系统: [e.g. macOS]
Taro 版本 [e.g. v.3.0.21]
Node.js 版本 [e.g. v12.4.0]
报错平台 [h5]
补充信息

@taro-bot2
Copy link

taro-bot2 bot commented Mar 23, 2021

您的 Issue 没有按照规范从 Taro Issue Helper 创建,因此会被直接关闭。

维护开源项目是一项非常辛苦的工作,还请多多包涵。
了解为什么这么严格?

@FLF1995 FLF1995 changed the title Taro.previewImage(),转换成H5嵌入app后,点击返回,图片预览不会关闭,始终显示图片预览状态。也没有方法可以关闭预览 问题描述 taro转换H5嵌入APP,调用Taro.previewImage后,点击返回,视图仍然是图片预览,但实际页面已经跳转 复现步骤 期望行为 图片预览关闭,而页面不会被回退。 报错信息 行为错误,无报错。 系统信息 Taro v1.2 及以上版本已添加 taro info 命令,方便大家查看系统及依赖信息,运行该命令后将结果贴下面即可。 操作系统: [e.g. macOS] Taro 版本 [e.g. v.3.0.21] Node.js 版本 [e.g. v12.4.0] 报错平台 [h5] 补充信息 无 Mar 23, 2021
@FLF1995 FLF1995 changed the title 问题描述 taro转换H5嵌入APP,调用Taro.previewImage后,点击返回,视图仍然是图片预览,但实际页面已经跳转 复现步骤 期望行为 图片预览关闭,而页面不会被回退。 报错信息 行为错误,无报错。 系统信息 Taro v1.2 及以上版本已添加 taro info 命令,方便大家查看系统及依赖信息,运行该命令后将结果贴下面即可。 操作系统: [e.g. macOS] Taro 版本 [e.g. v.3.0.21] Node.js 版本 [e.g. v12.4.0] 报错平台 [h5] 补充信息 无 Taro.previewIamge()H5环境下预览和返回问题 Mar 23, 2021
@lzs2000131
Copy link

lzs2000131 commented Apr 1, 2021

H5是要点击图片才能关闭的,可以自己写一段来点击返回的时候触发一下点击图片来关闭图片

previewImage: function (current, urls) {
    function bindingClick() {
      if (document.querySelector('.preview-image')) {
        document.querySelector('.preview-image').onclick = null
        document.querySelector('.preview-image').click()
      }
    }
    if (process.env.TARO_ENV === 'h5') {
      window.history.pushState(null, "title", location.href);
      window.addEventListener("popstate", bindingClick)
    }
    Taro.previewImage({
      current: current,
      urls: urls,
      success: function () {
        if (process.env.TARO_ENV === 'h5') {
          document.querySelector('.preview-image').onclick = () => {
            window.removeEventListener("popstate", bindingClick)
            history.back()
          }
        }
      }
    })
  }

@Chen-jj Chen-jj closed this as completed Apr 25, 2021
@lzs2000131
Copy link

后来发现H5的previewImage不能双指放大,最终在H5上使用了PhotoSwipe作为替代

@zprao
Copy link

zprao commented Sep 16, 2021

后来发现H5的previewImage不能双指放大,最终在H5上使用了PhotoSwipe作为替代

你是怎么实现的,引用了一个第三方库吗?

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

No branches or pull requests

4 participants