我有用JavaScript代码编写的let input= document.querySelector("#input");和
input.addEventListener('click', function() {
canvas.getContext('2d').drawImage(input, 0, 0, canvas.width, canvas.height);
let image_data_url = canvas.toDataURL('image/jpeg');
});我想用角写这段代码,如何在angular9项目中转换和使用这些代码?
发布于 2022-07-04 06:21:08
最好的方法是这样做:
<input (click)="clickOnMyInput($event)">在你的.ts文件中
clickOnMyInput(e){
this.canvas.getContext('2d').drawImage(e.target, 0, 0, this.canvas.width, this.canvas.height);
let image_data_url = this.canvas.toDataURL('image/jpeg');
}https://stackoverflow.com/questions/72852394
复制相似问题