解决columns里render绑定最外层父组件this
一、使用构造函数
constructor( props ){
super( props ) ;
let self = this;
this.columns = [{
title: '操作',
dataIndex: 'operation',
key: 'operation',
render(text,record,index) {
return (
<div className="">
<a style={{marginRight: 10}}>编辑</a>
<a onClick={() => self.delClick()}>删除</a>
</div>
);
}]
}
二、在columns前加this.columns;
三、使用变量let self = this;
四、在render时使用self.xxx()方法;
没有执行store里面的方法就加个’()’,让它执行
2.调用store里,并是store里的this有意义,我一把组件上的点击事件换成先触发一个事件,这个事件再去调用store里面的方法,store里面就可以读到this了,为什么,这两种操作有什么区别