收藏
回答

小程序office文件下载开发工具正常,真机调试文档损坏,每个文件大小都是16.7KB?

以下是我的代码:

wx.downloadFile({

        url: "https://XXX/test.docx",//docx链接

        success(res) {

          console.log(res);

          wx.getFileSystemManager().saveFile({

            tempFilePath: res.tempFilePath,

            filePath: wx.env.USER_DATA_PATH + '/' + 'test.docx',

            success(res) {

              console.log(res);

              wx.openDocument({

                filePath: res.savedFilePath,

                fileType: "docx",

                showMenu: true,

                success: function (res) {

                  wx.showToast({

                    title: '打开文档成功',

                  })

                  wx.hideLoading()

                },

                fail: function (res) {

                  wx.showToast({

                    title: '打开文档失败',

                  })

                  wx.hideLoading()

                },

              })

            },

            fail(err) {

              console.log(err)

            }

        }

        },

      })


最后一次编辑于  01-25
回答关注问题邀请回答
收藏
登录 后发表内容