【发布时间】:2021-05-09 00:12:07
【问题描述】:
我想试试 vue-html-to-paper,我根据文档做了最简单的设置。不过我使用的是 Vue3。
npm install vue-html-to-paper
//main.js
[...]
import VueHtmlToPaper from "vue-html-to-paper";
createApp(App)
.use(VueHtmlToPaper)
.mount("#app");
还有我的组件:
<template>
<div>
<div id="example">
Hello World
</div>
<button @click="print">
Print
</button>
</div>
</template>
<script>
export default {
name: "my_component",
methods: {
print: function() {
this.$htmlToPaper("example");
},
},
</script>
[...]
在开发时,我在控制台 [...] Cannot set property '$htmlToPaper' of undefined [...] 中收到错误消息。我做错了什么?
谢谢,不胜感激。
【问题讨论】:
标签: javascript vue.js printing vuejs3