wx.saveImageToPhotosAlbum手机上保存没反应?
发布于 7 年前 作者 xiulanding 11170 次浏览 来自 官方Issues

在开发工具中可以保存到电脑上,到了手机上 点确定后就一点反应都没有了,下面的弹窗一个 都不弹

wx.showModal({

     title: ‘提示’,

     content: ‘确定要保存这张图片吗?’,

     success: function (res) {

       if (res.confirm) {

         console.log(‘用户点击确定’)

         wx.downloadFile({

           url:that.data.images,

           success:function(res){

             console.log(res)

             if(res.statusCode == 200){

               let img = res.tempFilePath

               wx.saveImageToPhotosAlbum({

                 filePath: img,

                 success:function(res){

                   wx.showToast({

                     title: ‘保存成功!’,

                     icon: ‘none’,

                     duration: 2000

                   })

                 },

                 fail(res){

                   wx.showToast({

                     title: ‘保存失败!’,

                     icon: ‘none’,

                     duration: 2000

                   })

                 }

               })

             }else{

               wx.showToast({

                 title: ‘保存失败!’,

                 icon: ‘none’,

                 duration: 2000

               })

             }

           }

         })

       } else if (res.cancel) {

         wx.showToast({

           title: ‘取消保存!’,

           icon: ‘none’,

           duration: 2000

         })

       }

     }

   })

2 回复

已经解决了,是小程序没有配置 downloadFile合法域名

输出下fail看下输出什么?

回到顶部