<view
v-for="(item,index) in detail.enclosureList"
:key="index"
@click="fuBtn(item.linkAddress)">
附件:{{ item.file }}
</view>
// 获取数据截取名字
this.detail.fj.map(x=>{
let index = x.lastIndexOf("/");
let url = x.substring(0, index+1); // 链接域名例https://xxx.com/
let file = x.substring(index+1); // 链接名字例txt.pdf
this.detail.enclosureList.push({
url,
file,
linkAddress: x // 链接网址 例https://xxx.com/txt.pdf
})
})
// 点击附件预览
fuBtn(url) {
uni.downloadFile({
url,
success: function (res) {
let filePath = res.tempFilePath;
if (res.statusCode === 200) {
let filePath = res.tempFilePath;
uni.openDocument({
filePath: filePath,
showMenu: true,
success: function (res) {}
});
}
}
});
},
