js截图功能

 

    // setTimeout(() => {
    //   // 获取要导出的DOM
    //   const rect = document.getElementById('iklDetailAll').getBoundingClientRect()
    //   html2canvas(document.getElementById('iklDetailAll'), {
    //     width: rect.width,
    //     height: rect.height
    //   }).then(function (canvas) {
    //     const pageData = canvas.toDataURL('image/jpeg', 1.0)
    //     const imgData = pageData.replace('image/jpeg', 'image/octet-stream')
    //     const imgName = '生成图片.jpg'
    //     const save_link = document.createElementNS('http://www.w3.org/1999/xhtml', 'a')
    //     save_link.href = imgData
    //     save_link.download = imgName
    //     const event = document.createEvent('MouseEvents')
    //     event.initMouseEvent('click', true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null)
    //     save_link.dispatchEvent(event)
    //   })
    //
    // },3000)

 

posted @ 2022-10-28 09:19  从入门到入土  阅读(276)  评论(0编辑  收藏  举报