问题描述
我尝试使用Google查看器预览网站上的文档。我从blob获得文档网址,但是单击显示文档时出现错误。 在控制台中,我看到此链接:blob:http:// localhost:8080 / 5372d78d-a9c6-4c50-b23b-249cc643bdd2
const url = window.URL.createObjectURL(
new Blob([response.data],{ type: response.data.type })
);
const link = document.createElement("iframe");
console.log(url);
link.src = `https://docs.google.com/viewer?url=${url}&embedded=true`;
link.style.width = "100%";
link.style.height = "500px";
document.getElementById(fileId).appendChild(link);
},```
```async showDoc(file) {
this.fileId = file.Document.Id;
this.fileName = file.Document.Name;
try {
let response = await axios.get(url,{
responseType: "blob",params: {
fileId: this.fileId,},});
this.forceFileShow(response,this.fileId);
console.log("удача",response);
} catch (err) {
console.log("неудача",err.response);
}
}
},And here html:
<div class="card-icon" @click="showDoc(file)"
:data-target="`#showDoc${file.Document.Id}`"
data-toggle="modal">```
[1]: https://i.stack.imgur.com/tZlkm.png
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)