前端实现下载(ppt word excel)功能

代码:

 let blob = new Blob([this.form.marketingUrl], {

//this.form.marketingUrl 后端返回的存储地址

        type: 'application/pdf '  //指的是下载的文件的格式type

                });

          let a = document.createElement('a');

                    a.style.display = 'none';

                    a.download = '下载成功';

                    a.href = URL.createObjectURL(blob);

                    document.body.appendChild(a);

                    a.click();

                    document.body.removeChild(a);

pdf  type:application/pdf

ppt type:application/vnd.ms-powerpoint;charset=utf-8

excel trpe: application/vnd.openxmlformats-officedocument.wordprocessingml.document

world type:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8

你可能感兴趣的:(vue2,JavaScript,powerpoint,word,excel)