uploadfile 和 downloadfile 的 合法 域名也 填写 了。
//文件名
var te = e.currentTarget.dataset.text;
//计算出点的位置
var pos = te.lastIndexOf(".");
//截取点之后的字符串
var su = te.substring(pos + 1)
console.log(su);
console.log(config.serverUrl + 'Content/Upload/Files/' + e.currentTarget.dataset.text);
// ----------------------手机调试小程序时,打开调试模式。否则也可能会加载不出文档
wx.downloadFile({
url: config.serverUrl + 'Content/Upload/Files/' + e.currentTarget.dataset.text, // 可以是后台返回的地址。这里写的是死的
success: function (res) {
var filePath = res.tempFilePath; // 小程序中文件的临时文件
console.log(filePath);
wx.openDocument({
filePath: filePath,
// 文档打开格式记得写上,否则可能不能打开文档。 文档类型只能是一个
// 若是想打开多种类型的文档,可以解析文档地址中的文档格式,动态复制到fileTpye参数
fileType: su,
success: function (res) {
console.log('打开文档成功')
},
fail: (e) => {
console.log(e);
}
})
}
})
},
请具体描述问题出现的流程,并提供能复现问题的简单代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)。