wx.openDocument打开文件需要必填fileType?
发布于 5 年前 作者 xiaxu 1798 次浏览 来自 问答
// 下载文件
  downloadFiles:function(e){
    let path = e.currentTarget.dataset.url;
    wx.showLoading({
      title: '下载中...',
    });
    wx.downloadFile({
      url: ip + path,
      success(res) {
        if (res.statusCode === 200) {    
          wx.hideLoading();
          wx.openDocument({
            filePath: res.tempFilePath,
            success:function(res){
              console.log(res) 
            },
            fail:function(err){
              console.log(err)
            }
          })
        }
      }
    })
  }

文件下载时候按照官网给的参数配置fileType在opendocument时候是可以不填写的,

  1. 不填写fileType就会报错“{errMsg: "openDocument:fail filetype not supported"}”, 在开发者工具打开的 基础调试库为:2.9.4

  2. 填写fileType为我的文件格式类型后,打开的文件也和我上传的文件内容不一致..

3 回复

不支持你上传的文件类型

确认一下你的文件类型

填写了fileType为我的文件类型doc ,打开后却变成了html文件了…

回到顶部