PDF 直接通过url下载PDF文件(Pdf downloads PDF files directly through the URL)

普通文件可以直接 使用 a标签就可以下载,但是pdf会默认浏览器打开不是下载

为了实现点击下载引入  download.js  

GitHub – https://github.com/rndme/download


 1)如果是vue 直接执行 npm install downloadjs –save

 2)直接引入js文件 <script> 标签直接引入文件

第二步引入. import download from ‘downloadjs’

第三部使用 .download(文件路径,下载的文件名)

提示,如果想直接用文件路径中的文件名 可以使用下面代码获取 


Ordinary files can be downloaded directly using the a tag, but PDF will be opened in the default browser instead of downloading

In order to achieve Click to download   download.js

GitHub – https://github.com/rndme/download

Step 1 download

1) If it is Vue, directly execute NPM install downloadjs — save

2) Import JS file directly & lt; script> Labels are imported directly into the file

第二步引入. import download from ‘downloadjs’

The third part uses. Download (file path, downloaded file name)

Tip: if you want to directly use the file name in the file path, you can use the following code to get it