wx.openDocument打开文件需要必填fileType?

发布于 7 年前作者 xiaxu2110 次浏览最后编辑 7 年前来自 ask
// 下载文件
  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 回复
kangjie
kangjie1 楼6 年前

不支持你上传的文件类型

tao61
tao612 楼6 年前

确认一下你的文件类型

taosong
taosong3 楼5 年前

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