Wechat H5 page rendered with canvas images can not get base64 data?

Wechat H5 develops , and renders pictures on cdn with canvas . The cross-domain problem has been solved, but the data from canvas > to base64 is still not available on the real machine. (simulator and browser are fine)

has any god ever encountered this kind of problem? ask for a solution


because the image is loaded asynchronously, you need to make sure that your image has been loaded and then rendered to canvas, you can try img.onload this method. (if canvas wants to render multiple pictures, it is recommended that you consider the counter implementation. Use the toDataUrl method when the count reaches a certain point. The personal test is valid, hee hee)


some colleagues seem to have encountered a similar problem before, and the solution is to remove data:image/png;base64.

Menu