react组件里面的render函数外面与render函数里面的

2016-10-12  本文已影响0人  每一句话

<Button type="primary" onClick={this.showModal}>Open a modal dialog</Button>

onClick={this.showModal}  ---------》showModal()方法在组件里面render外面

onClick={showModal}        ------》showModal()方法在组件里面render里面(注意不需要加 this)

{

info(){ console.log(0); }

main(){

this.info();

},

在组件里面render外面写方法;直接像上面的写法;不需要function;

但是在render里面写方法时必须加上function;

同时在组件里面render外面的方法调用组件里面render外面的方法时;使用this.info()这样;

}

上一篇 下一篇

猜你喜欢

热点阅读