downloadFile在下载excel文件时,给文件进行改名,但是下载完成会打开旧文件?
发布于 5 年前 作者 eluo 740 次浏览 来自 问答

参考别人解决https://developers.weixin.qq.com/community/develop/doc/00088255a94580d4142bc32e656400的时候看到的解决方案

但是这样如果不同项目下 文件夹名称一样 会自动打开旧文件 而不会打开新文件

3 回复

wx.downloadFile(

              {

              url:url,

              // filePath:wx.env.USER_DATA_PATH+'/'+this.data.fileName,

              success: function (res) {

                console.log(res)

                const filePath = res.tempFilePath;

                // const filePath=res.filePath;

                console.log(filePath);

                wx.openDocument({

                  filePath: filePath,

                  fileType: 'xlsx',

                  showMenu: true,

                  success: function (res) {

                    console.log('打开文档成功')

                    wx.hideLoading()

                  },

                  fail: function (res) {

                    console.log(res);

                  },

                  complete: function (res) {

                    console.log(res);

                  }

                })

              },

这样写 打开的数据就正常 但是文件夹名称是乱码的 把注释切回来 filepath换了 出来的就是改之后的文件夹名 但是会打开旧文件 而不是新下载的文件

把名字改成选择文件的名字呐

垃圾啊啦啦啦痢疾杆菌矮灵祭管理机构

回到顶部