iOS(safari浏览器) 图片不能长按识别下载

208 阅读1分钟

iOS(safari浏览器) 图片不能长按识别下载

解决办法:

  1. image标签更换成img标签,解决图片保存本地问题
  2. 自定义下载图片方法
saveImageToPhotosAlbum(){
     
      let _this = this;
      if(!_this.shareInfo.posterImg) return false;
      wx.showLoading({
        title:'正在保存...',
        mask:true
      })
      wx.downloadFile({
        url:_this.shareInfo.posterImg,
        success(res){
          wx.saveImageToPhotosAlbum({
            filePath:res.tempFilePath,
            success:function(){
              wx.showToast({
                title:'保存成功~',
                icon:'success',
                duration:2000
              })
              _this.cancel()
              _this.$emit('saveSuccess')
            },
            fail:function(err){
              wx.hideLoading()
              _this.showTips = true
            }
          })
        },
        fail:function(){
          wx.hideLoading()
        }
      })
    }

这里用的是uniapp 默认下载图片的方法,仅供参考,根据自己的业务需求进行修改