captureScreen在真机上返回.unknown文件
发布于 6 年前 作者 hzhao 14991 次浏览 来自 问答
        const canI = wx.canIUse('captureScreen');
        if (canI) {
            wx.captureScreen({
                success: (res) => {
                    console.log('屏幕截屏', res);
                    wx.saveImageToPhotosAlbum({
                        filePath: res.tempFilePath,
                        success: () => {
                            console.log('图片保存成功');
                            wx.showToast({ title: '图片保存成功' })
                        },
                        fail: (e) => {
                            console.log('saveImageToPhontosAlbum  fail', e);
                        },
                        complete: () => {
                            console.log('saveImageToPhontosAlbum  complete');
                        }
                    });
                },
                fail: (e) => {
                    console.log('captureScreen fail', e);
                },
                complete: () => {
                    console.log('captureScreen complete');
                }
            });
        }


我想实现的是,用户在点击按钮的时候,触发屏幕截图功能,同时把图片保存到手机相册里。

以上代码在编辑器里运行正常,在真机上返回 wxfile://tmp_xxxxxx.unknown  文件。

求解决。

1 回复

我再补充一下,我在编辑器里截图能保存图片。保存后的图片文件  tmp_1693755463o6zAJs6DWW6t2S7DO97XizvVEyQY15309e1c8b287e0270650a6d3e6f5215.pnm 后缀是.pnm,而且保存的图片不是整屏,大约只有四分之一的截图。

回到顶部