Html2canvas: 如何将背景色设置为透明?

创建于 2017-07-12  ·  6评论  ·  资料来源: niklasvh/html2canvas

将选项中的背景设置为#ffffff后,我的画布的颜色为白色,可以,但是除画布图像以外的其余区域都是透明的,我该如何将该剩余区域也设置为一种颜色,例如白色?

最有用的评论

html2canvas(canvasDom, { allowTaint: true, useCORS: true, backgroundColor: "rgba(0,0,0,0)", removeContainer: true, x: 0, y: 0, width: 374, height: 722 })

所有6条评论

您可以将backgroundColornull以使其透明或使用任何颜色以使画布以背景色呈现

在这里,更改backgroundColor选项具有效果,但是将其更改为null会在画布中创建黑色背景,而CSS中没有黑色背景。

当将backgroundColor设置为null时,我也使画布呈现黑色背景

html2canvas(canvasDom, { allowTaint: true, useCORS: true, backgroundColor: "rgba(0,0,0,0)", removeContainer: true, x: 0, y: 0, width: 374, height: 722 })

allowTaint: truebackgroundColor: "rgba(0,0,0,0)"解决了问题

我认为allowTaint在解决此问题方面没有任何帮助。 为了我
backgroundColor: 'rgba(0, 0, 0, 0)', removeContainer: true,
设置是需要的。

此页面是否有帮助?
0 / 5 - 0 等级

相关问题

arzyu picture arzyu  ·  3评论

kunal886496 picture kunal886496  ·  3评论

stevencherry1 picture stevencherry1  ·  3评论

celik75 picture celik75  ·  4评论

yasergh picture yasergh  ·  5评论