Closed sooboy closed 6 years ago
Hello, I am trying to bind "this" to "elementOpen":
class Link extends Render implements ILinker { constructor( public title: string, public url: string, ) { super(); } public click() { window.location.href = this.url; } public render() { elementOpen("a", null, null, "onclick", ()=>console.log("ok",this), ); text("123"); elementClose("a"); } }
when I click :
this is undefined,How to bind this.click to elementOpen
this
undefined
this.click
elementOpen
"onclick", ()=>this.click(),
My expression is not very accurate, I hope you can understand;
I have solved it.
Hello, I am trying to bind "this" to "elementOpen":
when I click :
this
isundefined
,How to bindthis.click
toelementOpen
My expression is not very accurate, I hope you can understand;