用新的Image()在JavaScript中旋转图像

SIM*_*ITO 5 html javascript css image rotation

我尝试使用我尝试过的方式在javascript中旋转图像new Image():

this.gunner = new Image()
this.gunner.src = *url*
this.gunner.style.WebkitTransform = "rotate(20deg)"
Run Code Online (Sandbox Code Playgroud)

但图像仍然像正常一样.

我怎样才能做到这一点?

mel*_*amy 3

尝试这个:

var image = new Image();
image.src = 'http://placehold.it/350x150';
document.body.append(image);
image.style.transform = "rotate(90deg)";
Run Code Online (Sandbox Code Playgroud)