日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

html2canvas input,html2canvas 将html绘制到canvas中 [不建议使用]

發布時間:2025/3/21 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 html2canvas input,html2canvas 将html绘制到canvas中 [不建议使用] 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

這個有很多隱藏的bug, 不太建議在生產環境中使用

推薦使用vdom包裝一層, 用fabric畫到canvas中, 或者用后端去畫, 再或者用無頭瀏覽器去截圖

而且對于mac和windows的chrome表現也不一致....

下面是轉換出來的canvas, 用beta版本還可以接受, 但是依然丟失了文字

用官方的版本轉換出來的有問題

body {

width: 100vw;

height: 100vh;

display: flex;

justify-content: center;

align-items: center;

flex-direction: column;

}

.wrap {

width: 300px;

height: 300px;

display: flex;

justify-content: center;

align-items: center;

position: relative;

border: 1px solid blue;

}

.bg-img {

width: 100%;

height: 100%;

background: url("./t.jpg") no-repeat;

background-position-x: center;

background-position-y: center;

background-size: contain;

}

.text-input {

width: 400px;

height: 200px;

border: 1px solid red;

background: gray;

opacity: .5;

position: absolute;

}

show

function showCanvas() {

html2canvas(document.querySelector(".wrap", {

width: 300,

height: 300

})).then(canvas => {

document.body.appendChild(canvas)

});

}

總結

以上是生活随笔為你收集整理的html2canvas input,html2canvas 将html绘制到canvas中 [不建议使用]的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。