1. 安装
npm install html2canvas --save
2. 引用
import html2canvas from 'html2canvas'
html2canvas(document.querySelector('#printing' + oper)).then(canvas => {
window.document.body.innerHTML = ''
document.body.appendChild(canvas)
window.print() // 打印
location.reload()
})
3. 遇到的问题
当时遇到echart图表打印不出来= =为空,但是忘记怎么解决了= =
不用location.reload 可以 将原先的body.html放回去就可以了