1、問題描述:
點擊文字-打開文件進行預(yù)覽:文章來源:http://www.zghlxwxcb.cn/news/detail-408838.html
2、解決:
使用uni.openDocument
新開頁面打開文檔,支持格式:doc, xls, ppt, pdf, docx, xlsx, pptx。文章來源地址http://www.zghlxwxcb.cn/news/detail-408838.html
<view class="formwork" @click="openFile()">
點擊查看公司授權(quán)書模板展示
</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>
到了這里,關(guān)于uniapp 開發(fā)小程序——點擊預(yù)覽文件的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!