annexClick(item) {
let fileurl=formatPic(item.attchPath.replace(/\\/g,'/'))
uni.downloadFile({
url: fileurl,
success: function(res) {
var filePath = res.tempFilePath;
uni.openDocument({
filePath: filePath,
showMenu: true,
success: function(res) {
console.log('打开文档成功');
},
fail: function(err) {
uni.showToast({
icon: 'none',
mask: true,
title: err.errMsg,
duration: 3000,
});
}
});
},
fail: function(err) {
uni.showToast({
icon: 'none',
mask: true,
title: err.errMsg,
duration: 3000,
});
}
});
},
uniapp打开手机端的第三方word,文件浏览器
最新推荐文章于 2026-06-22 16:34:29 发布
该代码段展示了在uni-app中如何处理点击事件下载文件,然后使用uni.openDocument打开文档。它首先将文件路径转换,接着下载文件,如果成功则打开文档,失败时显示错误信息。

4697

被折叠的 条评论
为什么被折叠?



