我无法让 html2canvas 为文本添加下划线。根据我对包的理解,支持下划线。我能够保存图像并且没有遇到任何其他 CSS 属性的问题。有什么想法吗?
这是我的测试代码:
<html>
<head>
<script src="/jquery-1.10.2.min.js"></script>
<script language="javascript" type="text/javascript" src="/html2canvas.js"></script>
<script language="javascript" type="text/javascript" src="/jquery.plugin.html2canvas.js"></script>
<script language="javascript" type="text/javascript">
<!--
function save(div)
{
html2canvas([document.getElementById('img')], { background:'#fff',
onrendered: function(canvas)
{
var img = canvas.toDataURL("image/png")
$.post("save.php", {data: img, prefix: 'test'});
}
});
}
-->
</script>
</head>
<body bgcolor="white">
<div id="img" style="background-color:white; width:304px; float:left; height:104px; border-radius:10px; border:3px solid white;">
<div style="width:125px;"></div>
<div style="width:175px; padding:0px;">
<u>Test</u>
<span style="text-decoration:underline;">Test2</span>
</div>
</div>
<input type="button" onClick="save();" value="Save!">
<br><br>
</body>
</html>
最佳答案
只是想知道是否转换:
$.post("save.php", {data: img, prefix: 'test'});
到:
var tempObj = {prefix:'test'};
tempObj[data] = img;
$.post("save.php", tempObj);
有帮助,因为我曾经遇到过问题,因为我在 data: img
中有两个变量作为键值对,并使用 tempObj[data] = img
解决了反而。看看它是否有效。
此外,您的整个 JS 都在 <!--
中这肯定会导致语法错误。
关于javascript - 下划线在 html2canvas 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22417961/