1.通过接口请求文件,返回类型是blob类型

this.$axios
          .get(
           url,
            {
              responseType: 'blob',
            } // 服务器上pdf路径
          )
          .then((res) => {
            console.log(typeof res,  res)
            const a = document.createElement('a');
            const url = window.URL.createObjectURL(res);
            a.href = url;
            a.download = `支付凭证-${new Date().toLocaleString().split(' ')[0]}`;
            a.click();
            window.URL.revokeObjectURL(url);
Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐