Issue
I want to create a Image data and rewrite onload function , but this
can't point to newImage
in typescript. what can i do to make this
pointer point to newImage
Solution
You can tell TypeScript which type this
should have by adding it as a function parameter:
function onload(this: HTMLImageElement) {
const {width, height} = this
}
The parameter will be ignored when compiling to JavaScript.
See https://www.typescriptlang.org/docs/handbook/2/functions.html#declaring-this-in-a-function
Answered By - benS
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.