【发布时间】:2018-06-05 13:12:22
【问题描述】:
我有一个要打印的 vueJS 组件。但是,当我使用标准打印对话框时,我会丢失所有 CSS,基本上只有纯文本。
我也试过 Printd。
我的代码是这样的:
mounted () {
this.cssText = `
.a4-paper {
height: 29cm;
width: 14cm;
}
h4, h3, h2, h1 {
text-align: center;
width: 100%;
}
label.underline {
border-bottom: solid black 1px;
height: 0.3cm;
width: 100%;
}`;
this.d = new Printd()
},
methods: {
show(event: Event) {
this.event = event;
this.visible = true;
},
print() {
this.d.print(this.$el, this.cssText)
}
}
但是,结果看起来与组件的呈现方式完全不同。我一直无法找到解决方案。有人可以帮帮我吗?
【问题讨论】:
标签: vue.js printing html-to-pdf html-pdf