我試圖在 Vue.js 中使用 htlm2canvas 來截取一個 div 的截圖,但它給出了以下錯誤:
無法讀取未定義的屬性(讀取“ownerDocument”)
我是否必須在要使用的組件中匯入某些內容?我沒有找到這個庫的任何檔案。
主要.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 ref="printme" >
///elements
</div>
方法:
async print() {
const el = this.$refs.printMe
const options = {
type: 'dataURL',
}
this.output = await this.$html2canvas(el, options)
},
安裝:
mounted() {
this.print()
},
uj5u.com熱心網友回復:
有一個錯字
<div ref="printMe" >
///elements
</div>
注意:我已更改printme為printMe
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/378497.html
下一篇:反應式默認道具值
