如何解决Google Document Viewer显示:由于格式错误,服务器无法处理该请求
我尝试使用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 举报,一经查实,本站将立刻删除。