1、问题描述:
点击文字-打开文件进行预览:
2、解决:
使用uni.openDocument
新开页面打开文档,支持格式:doc, xls, ppt, pdf, docx, xlsx, pptx。
<view class="formwork" @click="openFile()">
点击查看公司授权书模板展示
</view>
<script>
//打开文件
openFile() {
uni.downloadFile({
url: this.hostUrl + '/static/index/prove.docx', //文件的路径
success: function(res) {
var filePath = res.tempFilePath;
uni.openDocument({
filePath: filePath,
showMenu: true,
success: function(res) {
console.log('打开文档成功');
}
});
}
});
},
</script>