使用方法就不介绍了,去下面看吧
https://github.com/brinley/jSignature
一、问题描述
想通过颜色对话框动态设置签名的笔触颜色,但网上找了很久没找到方法,在发布页找到了下面这句话
updateSetting
takes three arguments - setting name, new value, boolean value if the change should affect current signature or future strokes. This allows you to update certain settings like lineWidth or line color and with the third argument you can make the change apply to the existing strokes. At present, updating change to existing strokes only works with a few settings like color. Returns the updated value.
二、解决办法
1、添加颜色对话框
<input type="color" id="fcolor" onchange="changefcolor()">
2、js代码这样写
function changefcolor() { ////此方法表面有效,但实际颜色未成功设置,导出的图片也无颜色,放弃 ////var context2D = $("#signature").find('canvas')[0].getContext('2d'); ////context2D.strokeStyle = $("#fcolor").val(); //使用前,清除现有笔迹,因为一次只允许使用一种颜色 $('#signature').jSignature("updateSetting", "color", $("#fcolor").val(), true); }
已有 5267 位网友参与,快来吐槽:
发表评论