【发布时间】:2021-02-21 18:23:24
【问题描述】:
我正在使用 puppeteer 创建 HTML 页面的 PDF,它使用 Vue 和 Vuetify:
import { launch } from 'puppeteer';
.
.
.
const browser = await launch({ headless: false });
const page = await browser.newPage();
page.setContent(html, { waitUntil: 'networkidle0' });
const pdf = await page.pdf({ format: 'A4' });
await browser.close();
return pdf
HTML 看起来类似于:
<html>
<body>
<div id="app"> ... VUE & VUETIFY COMPONENT</div>
<script src="https://cdn.jsdelivr.net/npm/vue@2.6.11/dist/vue.js" ></script>
<script src="https://cdn.jsdelivr.net/npm/vuetify@2.3.10/dist/vuetify.js" ></script>
<script>
const app = new Vue({
el: '#app',
vuetify: new Vuetify(),
data() {} .....
});
</script>
</body>
</html>
但是当浏览器打开时,看起来 Vue 和 Vuetify 没有正确加载。
【问题讨论】:
标签: javascript html vue.js vuetify.js puppeteer