【问题标题】:Cannot read properties of undefined (reading 'ownerDocument')无法读取未定义的属性(读取“ownerDocument”)
【发布时间】: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


    【解决方案1】:

    有错别字

    <div ref="printMe" class="content">
    ///elements
    </div>
    

    注意:我已将printme 更改为printMe

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-01-26
      • 2013-07-09
      • 2023-03-11
      • 2022-01-15
      • 2021-12-31
      • 2021-12-13
      • 2021-11-28
      • 2021-11-15
      相关资源
      最近更新 更多