解决内存泄漏问题

This commit is contained in:
yangchch6 2019-07-18 11:25:29 +08:00
parent ddb6386de4
commit bc94da12e7
7 changed files with 14 additions and 2 deletions

View File

@ -332,6 +332,7 @@ var Table = function (_Component) {
_this.computeTableWidth = _this.computeTableWidth.bind(_this); _this.computeTableWidth = _this.computeTableWidth.bind(_this);
_this.onBodyMouseLeave = _this.onBodyMouseLeave.bind(_this); _this.onBodyMouseLeave = _this.onBodyMouseLeave.bind(_this);
_this.tableUid = null; _this.tableUid = null;
_this.contentTable = null;
return _this; return _this;
} }
@ -418,6 +419,7 @@ var Table = function (_Component) {
}; };
Table.prototype.componentWillUnmount = function componentWillUnmount() { Table.prototype.componentWillUnmount = function componentWillUnmount() {
this.contentTable = null;
_utils.EventUtil.removeHandler(this.contentTable, 'keydown', this.onKeyDown); _utils.EventUtil.removeHandler(this.contentTable, 'keydown', this.onKeyDown);
_utils.EventUtil.removeHandler(this.contentTable, 'focus', this.onFocus); _utils.EventUtil.removeHandler(this.contentTable, 'focus', this.onFocus);
if (this.resizeEvent) { if (this.resizeEvent) {

View File

@ -471,6 +471,7 @@ var TableHeader = function (_Component) {
_this._thead = null; //当前对象 _this._thead = null; //当前对象
_this.event = false; //避免多次绑定问题 _this.event = false; //避免多次绑定问题
_this.lastColumWidth = null; //非固定列最后一列的初始化宽度 _this.lastColumWidth = null; //非固定列最后一列的初始化宽度
_this.fixedTable = {};
return _this; return _this;
} }
@ -487,6 +488,7 @@ var TableHeader = function (_Component) {
}; };
TableHeader.prototype.componentWillUnmount = function componentWillUnmount() { TableHeader.prototype.componentWillUnmount = function componentWillUnmount() {
this.fixedTable = null;
if (!this.table) return; if (!this.table) return;
if (this.props.draggable) { if (this.props.draggable) {
this.removeDragAbleEvent(); this.removeDragAbleEvent();
@ -495,6 +497,7 @@ var TableHeader = function (_Component) {
this.removeDragBorderEvent(); this.removeDragBorderEvent();
} }
this.eventListen([{ key: 'mousedown', fun: this.onTrMouseDown }], 'remove', this.table.tr[0]); this.eventListen([{ key: 'mousedown', fun: this.onTrMouseDown }], 'remove', this.table.tr[0]);
this.eventListen([{ key: 'mouseup', fun: this.bodyonLineMouseUp }], 'remove', document.body);
}; };
/** /**

2
dist/demo.js vendored
View File

@ -34184,6 +34184,7 @@
_this.computeTableWidth = _this.computeTableWidth.bind(_this); _this.computeTableWidth = _this.computeTableWidth.bind(_this);
_this.onBodyMouseLeave = _this.onBodyMouseLeave.bind(_this); _this.onBodyMouseLeave = _this.onBodyMouseLeave.bind(_this);
_this.tableUid = null; _this.tableUid = null;
_this.contentTable = null;
return _this; return _this;
} }
@ -37873,6 +37874,7 @@
_this._thead = null; //当前对象 _this._thead = null; //当前对象
_this.event = false; //避免多次绑定问题 _this.event = false; //避免多次绑定问题
_this.lastColumWidth = null; //非固定列最后一列的初始化宽度 _this.lastColumWidth = null; //非固定列最后一列的初始化宽度
_this.fixedTable = {};
return _this; return _this;
} }

2
dist/demo.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,6 @@
{ {
"name": "bee-table", "name": "bee-table",
"version": "2.1.7-beta.0", "version": "2.1.7-beta.4",
"description": "Table ui component for react", "description": "Table ui component for react",
"keywords": [ "keywords": [
"react", "react",

View File

@ -153,6 +153,7 @@ class Table extends Component {
this.computeTableWidth = this.computeTableWidth.bind(this); this.computeTableWidth = this.computeTableWidth.bind(this);
this.onBodyMouseLeave = this.onBodyMouseLeave.bind(this); this.onBodyMouseLeave = this.onBodyMouseLeave.bind(this);
this.tableUid = null; this.tableUid = null;
this.contentTable = null;
} }
componentDidMount() { componentDidMount() {
@ -243,6 +244,7 @@ class Table extends Component {
} }
componentWillUnmount() { componentWillUnmount() {
this.contentTable = null;
EventUtil.removeHandler(this.contentTable,'keydown',this.onKeyDown); EventUtil.removeHandler(this.contentTable,'keydown',this.onKeyDown);
EventUtil.removeHandler(this.contentTable,'focus',this.onFocus); EventUtil.removeHandler(this.contentTable,'focus',this.onFocus);
if (this.resizeEvent) { if (this.resizeEvent) {

View File

@ -32,6 +32,7 @@ class TableHeader extends Component {
this._thead = null;//当前对象 this._thead = null;//当前对象
this.event = false;//避免多次绑定问题 this.event = false;//避免多次绑定问题
this.lastColumWidth = null;//非固定列最后一列的初始化宽度 this.lastColumWidth = null;//非固定列最后一列的初始化宽度
this.fixedTable = {};
} }
static defaultProps = { static defaultProps = {
@ -51,6 +52,7 @@ class TableHeader extends Component {
} }
componentWillUnmount(){ componentWillUnmount(){
this.fixedTable = null;
if(!this.table)return; if(!this.table)return;
if (this.props.draggable){ if (this.props.draggable){
this.removeDragAbleEvent(); this.removeDragAbleEvent();
@ -59,6 +61,7 @@ class TableHeader extends Component {
this.removeDragBorderEvent(); this.removeDragBorderEvent();
} }
this.eventListen([{key:'mousedown',fun:this.onTrMouseDown}],'remove',this.table.tr[0]); this.eventListen([{key:'mousedown',fun:this.onTrMouseDown}],'remove',this.table.tr[0]);
this.eventListen([{key:'mouseup',fun:this.bodyonLineMouseUp}],'remove',document.body);
} }
/** /**