要求通过地址获取文件流 但是我这边需要在header中带token 所以 直接访问window.open(url)地址报没有权限
所以通过访问接口地址返回文件流通过流文件创建文件对象展示在新的窗口。
handlePreview (file) {
const _this = this
_this.$http({
url: _this.$http.adornUrl('file/' + file.url),
method: 'get',
responseType: 'blob',
}).then(({ data }) => {
window.open(window.URL.createObjectURL(data), '_blank')
})
},