<button data-src="地址" bindtap="previewPDF" class="record-style">pdf名称</button>
.record-style{ margin: 0; margin-top: 15rpx; padding: 0; text-align: left; background: #f2f2f2; font-size: 26rpx; color: #169bd5;}
.record-style::after{ border: 0}
//查看pdf
previewPDF(e){
wx.downloadFile({
url: e.currentTarget.dataset.src,
success: function (res) {
var filePath = res.tempFilePath
wx.openDocument({
fileType: 'pdf', // 需要写上文件类型才能预览,不让回找系统应用打开,体验不好
filePath: filePath,
success: function (res) {
console.log('打开文档成功!')
}
})
}
})
},