NodeJS使用wkhtmltopdf转pdf、html vue转pdf、Highcharts转pdf遇到的坑

一、使用 wkhtmltopdf 中遇到的坑

1、wkhtmltopdf 对vue支持不好,使用created() {},可以正常执行,mounted() 无法执行。

2、如果前端框架使用nuxt.js,可以在Nuxt.js项目中的asyncData ()获取接口数据。

3、如果非vue框架,建议使用原生js获取数据,不支持let、“、jquery。

二、wkhtmltopdf  常用参数解释

wkhtmltopdf  使用 javascriptDelay 延迟加载

wkhtmltopdf  传递 cookie

三、axios 下载文件方法

this.$axios({

                url: '',

                method: 'GET',

                responseType: 'blob', // important

            }).then((response) => {

                this.loading1 = false;

                const url = window.URL.createObjectURL(new Blob([response.data]));

                const link = document.createElement('a');

                link.href = url;

                link.setAttribute('download', 'example.zip');

                document.body.appendChild(link);

                link.click();

            }).catch((err) => {

                console.log(err);

          });

原创文章 7 获赞 0 访问量 482

猜你喜欢

转载自blog.csdn.net/csdn_1112/article/details/105716304