In many react compon原创内容,盗版必究。【版权所有,侵权必究】ent’s construc【作者:唐霜】著作权归作者所有,禁止商业用途转载。tor, developers alwa【原创不易,请尊重版权】【版权所有】唐霜 www.tangshuang.netys bind its methods 原创内容,盗版必究。【未经授权禁止转载】with this, like:
【访问 www.tangshuang.net 获取更多精彩内容】原创内容,盗版必究。【关注微信公众号:wwwtangshuangnet】【作者:唐霜】【关注微信公众号:wwwtangshuangnet】export default class MyComponent extends Component {
constructor() {
this.say = this.say.bind(this)
}
...
}
This sentence seems 著作权归作者所有,禁止商业用途转载。著作权归作者所有,禁止商业用途转载。to be stupid. Is thi本文作者:唐霜,转载请注明出处。【访问 www.tangshuang.net 获取更多精彩内容】s regulated by react【本文受版权保护】未经授权,禁止复制转载。?
【本文受版权保护】转载请注明出处:www.tangshuang.net【未经授权禁止转载】转载请注明出处:www.tangshuang.net【作者:唐霜】No!【版权所有,侵权必究】
著作权归作者所有,禁止商业用途转载。【访问 www.tangshuang.net 获取更多精彩内容】原创内容,盗版必究。In fact, react compo【原创不易,请尊重版权】【版权所有,侵权必究】nent class follow ES著作权归作者所有,禁止商业用途转载。著作权归作者所有,禁止商业用途转载。6 class std. The rea转载请注明出处:www.tangshuang.net【版权所有】唐霜 www.tangshuang.netson to put this sent【版权所有】唐霜 www.tangshuang.net【未经授权禁止转载】ence is because when【未经授权禁止转载】未经授权,禁止复制转载。 you use this.say in本文作者:唐霜,转载请注明出处。转载请注明出处:www.tangshuang.net your render, you al【访问 www.tangshuang.net 获取更多精彩内容】【本文首发于唐霜的博客】way use it as onClic本文版权归作者所有,未经授权不得转载。【版权所有】唐霜 www.tangshuang.netk callback function,【作者:唐霜】【原创内容,转载请注明出处】 this is why this is未经授权,禁止复制转载。【本文首发于唐霜的博客】 not point to instan【原创内容,转载请注明出处】转载请注明出处:www.tangshuang.netce of this component【原创内容,转载请注明出处】本文版权归作者所有,未经授权不得转载。. Let’s look i未经授权,禁止复制转载。著作权归作者所有,禁止商业用途转载。nto this code:
转载请注明出处:www.tangshuang.net本文版权归作者所有,未经授权不得转载。【未经授权禁止转载】【版权所有,侵权必究】本文作者:唐霜,转载请注明出处。<a href="" onclick="alert(this.href)">click</a>
You know what this p著作权归作者所有,禁止商业用途转载。【原创内容,转载请注明出处】oint to here, so whe【本文受版权保护】【版权所有】唐霜 www.tangshuang.netn you use a componen原创内容,盗版必究。【本文受版权保护】t method as a event 本文版权归作者所有,未经授权不得转载。著作权归作者所有,禁止商业用途转载。callback function, t转载请注明出处:www.tangshuang.net【作者:唐霜】his in the function 【版权所有】唐霜 www.tangshuang.net【关注微信公众号:wwwtangshuangnet】does not referer to 【本文首发于唐霜的博客】【转载请注明来源】the instance of comp原创内容,盗版必究。【关注微信公众号:wwwtangshuangnet】onent. So another wa本文作者:唐霜,转载请注明出处。【版权所有】唐霜 www.tangshuang.nety to solve this prob未经授权,禁止复制转载。本文作者:唐霜,转载请注明出处。lem is to bind this 【作者:唐霜】转载请注明出处:www.tangshuang.netwhen you use the met本文版权归作者所有,未经授权不得转载。本文版权归作者所有,未经授权不得转载。hod, like:
本文作者:唐霜,转载请注明出处。本文版权归作者所有,未经授权不得转载。【本文受版权保护】本文作者:唐霜,转载请注明出处。【转载请注明来源】export default class MyComponent extends Component {
constructor() {
// do not use bind sentence
}
render() {
return <a onClick={this.say.bind(this)}>click</a>
}
}
Now you can use this原创内容,盗版必究。【关注微信公众号:wwwtangshuangnet】 in say as want you 原创内容,盗版必究。本文作者:唐霜,转载请注明出处。want.
【版权所有】唐霜 www.tangshuang.net本文版权归作者所有,未经授权不得转载。转载请注明出处:www.tangshuang.net本文版权归作者所有,未经授权不得转载。
