【发布时间】:2023-03-08 05:31:01
【问题描述】:
我正在尝试在 Vue.js 中使用 htlm2canvas 来截取 div 的屏幕截图,但它给出了以下错误:
无法读取未定义的属性(读取 'ownerDocument')
我必须在我想使用的组件中导入一些东西吗?我没有找到这个库的任何文档。
Main.js:
import Vue from 'vue'
import VueHtml2Canvas from 'vue-html2canvas'
import BabelPolyfill from '@babel/polyfill'
Vue.use(BabelPolyfill)
Vue.use(VueHtml2Canvas)
new Vue({
router,
store,
render: h => h(App),
}).$mount('#app')
目标 div:
<div ref="printme" class="content">
///elements
</div>
方法:
async print() {
const el = this.$refs.printMe
const options = {
type: 'dataURL',
}
this.output = await this.$html2canvas(el, options)
},
已安装:
mounted() {
this.print()
},
【问题讨论】:
标签: vue.js html2canvas