StarFire_xm
  • 文章
  • 粉丝
  • 评论

微信下载文件重命名并打开

2025-07-11 12:28:520 次浏览0 次评论技能类型: 微信
wx.downloadFile({
    url: response.data.fileUrl,//文件下载地址比如远程地址
    filePath: wx.env.USER_DATA_PATH + '/' + exportFilename + '.xlsx', //exportFilename  自己定义文件名
    success: function (res) { 
      if (res.statusCode == 200) {
        let filePath = res.filePath
        wx.openDocument({//打开文件
          fileType: 'xlsx',
          filePath: filePath,
          showMenu: true,
        })
      }
    },
    fail: function (error) {
      toast.error('导出失败')
    }
  })


    发表

    还没有评论哦,来抢个沙发吧!