var dataurl = canvas.toDataURL('image/png'); var dataurl2 = canvas.toDataURL('image/jpeg', 0.8);
转:https://blog.csdn.net/cuixiping/article/details/45932793