获取::: p时出错
未捕获(承诺)TypeError:window.URL.createObjectURL不是eval的函数
无法下载pdf
我的代码:
axios({
url: url,
method: 'GET',
responseType: 'blob',
headers: {
'Authorization': 'Bearer ' +localStorage.getItem('token'),
}
}).then((response) => {
const url = window.URL.createObjectURL(new Blob([response.data]));
const link = document.createElement('a');
link.href = url;
link.setAttribute('download', 'file.pdf'); //or any other extension
document.body.appendChild(link);
link.click();
});
后端:
public function getPDF(Request $request) {
$pdf = App::make('dompdf.wrapper');
$pdf->loadHTML('<h1><center>Test</center></h1>');
return $pdf->download('invoice.pdf');
}