Google chrome Google文档查看器显示:服务器无法处理请求,因为它的格式不正确
我尝试使用谷歌浏览器预览我网站上的文档。我从blob中获取的文档url,但当我单击以显示文档时,出现了一个错误。 在控制台中,我看到以下链接:blob:http://localhost:8080/5372d78d-a9c6-4c50-b23b-249cc643bdd2Google chrome Google文档查看器显示:服务器无法处理请求,因为它的格式不正确,google-chrome,vue.js,blob,preview,viewer,Google Chrome,Vue.js,Blob,Preview,Viewer,我尝试使用谷歌浏览器预览我网站上的文档。我从blob中获取的文档url,但当我单击以显示文档时,出现了一个错误。 在控制台中,我看到以下链接:blob:http://localhost:8080/5372d78d-a9c6-4c50-b23b-249cc643bdd2 const url = window.URL.createObjectURL( new Blob([response.data], { type: response.data.type })
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
const url=window.url.createObjectURL(
新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);
},```
```异步showDoc(文件){
this.fileId=file.Document.Id;
this.fileName=file.Document.Name;
试一试{
let response=wait axios.get(url{
响应类型:“blob”,
参数:{
fileId:this.fileId,
},
});
this.forceFileShow(响应,this.fileId);
控制台日志(“ааааа”,响应);
}捕捉(错误){
控制台日志(“错误响应”);
}
}
},
这里是html:
```
[1]: https://i.stack.imgur.com/tZlkm.png