1.图片路径后面加?any_string_is_ok
2.图片加crossOrigin="anonymous"属性
3.html2canvas加useCORS: true
4.前端跨域完成,如果安卓调用,安卓也要处理跨域
<img src="~@/assets/hosLogo.png?any_string_is_ok" crossOrigin="anonymous">
let pdfContent = document.querySelector('#AssessmentForm')
html2canvas(pdfContent, { scale: 2, useCORS: true }).then(async (canvas) => {
const contentWidth = canvas.width
const contentHeight = canvas.height
const pageHeight = (contentWidth / 560.28) * 829.89
let leftHeight = contentHeight
let position = 12