c***@163.com
c***@163.com
  • 发布:2021-11-29 15:46
  • 更新:2021-11-29 18:04
  • 阅读:785

图片预览无法关闭

分类:uni-app

使用uni.previewImage打开图片预览,长按图片会弹起选择框,点击其中一个按钮后需要打开一个新的页面,但此时调用uni.closePreviewImage无法关闭图片预览,三个回调都未执行

Hbulderx版本3.2.16

clickPicture() {  
                var self = this;  
                let url = $common.cacheImg(this.data.content.image_url);  
                getApp().globalData.filterShowHide = true;  
                uni.previewImage({  
                    urls: [url],  
                    current: 0,  
                    longPressActions: {  
                        itemList: ['举报'],  
                        success: function(data) {  
                            if (data.tapIndex == 0) {  
                                self.closePreviewImage(function () {  
                                    let params = {  
                                        type: self.data.chat_type,  
                                        targetId: self.data.chat_id  
                                    }  
                                    $common.openPage('/pagesPub/report/report', params);  
                                });  
                            }  
                        },  
                        fail: function(err) {  
                            console.log("uni.previewImage error ---> ", err.errMsg);  
                        }  
                    }  
                });  
            },  
            closePreviewImage(callback) {  
                uni.closePreviewImage({  
                    success: function() {  
                        if (typeof callback == "function") callback();  
                    },  
                    fail: function (error) {  
                        console.log("uni.closePreviewImage fail ---> ", error);  
                    },  
                    complete: function(res) {  
                        console.log("uni.closePreviewImage res ---> ", res);  
                    },  
                });  
            }
2021-11-29 15:46 负责人:无 分享
已邀请:
小枫叶

小枫叶 - 外包接单加v:wlmk1234567 注明来意

点击空白处也不行吗?

  • c***@163.com (作者)

    点击空白处是可以的,但我现在需要用代码关闭

    2021-11-30 14:17

DCMarvel

DCMarvel

现版本还不支持 uni.closePreviewImage 请使用plus.nativeUI.closePreviewImage();

  • c***@163.com (作者)

    更换后也不行......这个方法需要配置参数什么的吗?还是说打开预览也得用plus.nativeUI.对应的方法?

    我这个是在一个组件里使用,nvue页面的。

    2021-11-30 14:30

  • DCMarvel

    回复 c***@163.com: 没有任何参数和回调,uni.previewImage 也能关闭,看看自己哪里写错了吧

    2021-11-30 14:52

  • 1***@qq.com

    都不可以 没任何效果撒

    2021-12-02 11:13

该问题目前已经被锁定, 无法添加新回复