save

Interesting download error when trying to download html canvas as image with button

生来就可爱ヽ(ⅴ<●) 提交于 2020-11-30 00:11:55
问题 When I first click the button it doesn't work. On my second click it downloads 1 picture. My 3rd click it downloads 2 pictures. On my 4th click it downloads 3 pictures. So 1-0, 2-1, 3-2, 4-3. They are also downloaded immediately, it doesn't ask where to save. js: function xyz(){ const text =canvas.api.getCanvasAsImage(); const download = document.getElementById('download'); download.addEventListener('click', function(e) { var link = document.createElement('a'); link.download = 'download.png';

Interesting download error when trying to download html canvas as image with button

久未见 提交于 2020-11-30 00:05:12
问题 When I first click the button it doesn't work. On my second click it downloads 1 picture. My 3rd click it downloads 2 pictures. On my 4th click it downloads 3 pictures. So 1-0, 2-1, 3-2, 4-3. They are also downloaded immediately, it doesn't ask where to save. js: function xyz(){ const text =canvas.api.getCanvasAsImage(); const download = document.getElementById('download'); download.addEventListener('click', function(e) { var link = document.createElement('a'); link.download = 'download.png';