收藏
回答

openDocument 每次都有执行成功,但是文件经常打不开,要点好几次才能

框架类型 问题类型 API/组件名称 终端类型 微信版本 基础库版本
小程序 Bug openDocument 客户端 7.0.4 2.7.7


每次都执行打开成功,但是文件就是没有打开,要点好几次才会成功打开一次



wx.downloadFile({

url:'.........pdf',

success: (res) => {

wx.hideLoading();

wx.showLoading({

  title: '正在打开文件...',

  mask:true,

});

if (res.statusCode === 200) {

var filePath = res.tempFilePath;

wx.openDocument({

  filePath: filePath,

  fileType: 'pdf',

  success: function (res) {

  wx.hideLoading();

  console.log(res);

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

  },

  fail(res) {

  wx.showLoading({

    title: '打开文档失败',

    mask:true,

  });

    console.log(res);

  }

});

}

},

fail: (res) => {

wx.showToast({

  title: "下载失败",

  mask:true,

  icon: 'none'

});

}

});


回答关注问题邀请回答
收藏

1 个回答

  • 关小胖
    关小胖
    2019-07-20

    不是因为QQ浏览器,我QQ浏览器卸了还是那样,要点好几次才能打开,每次都返回打开成功

    2019-07-20
    有用
    回复 1
    • 关小胖
      关小胖
      2019-07-20
      setTimeout(()=>wx.openDocument({...}),1000),测试后发现每次就能打开了。
      2019-07-20
      回复
登录 后发表内容