From 5570b9027b30c8b6f11f1689a4552e7f1f703c81 Mon Sep 17 00:00:00 2001 From: ykforerlang <1527997464@qq.com> Date: Tue, 30 Jul 2019 10:56:03 +0800 Subject: [PATCH] =?UTF-8?q?perf(wx-react-native):=20FlatList,=20SectionLis?= =?UTF-8?q?t,=20Picker=20R=E4=B8=8E=5Fr=20=E5=88=87=E6=8D=A2=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../component/WXFlatList/index.js | 21 +-- .../component/WXFlatList/index.wxml | 147 +++++++++--------- .../component/WXPicker/index.js | 13 +- .../component/WXPicker/index.wxml | 41 ++--- .../component/WXSectionList/index.js | 14 +- .../component/WXSectionList/index.wxml | 119 +++++++------- 6 files changed, 183 insertions(+), 172 deletions(-) diff --git a/packages/wx-react-native/miniprogram_dist/component/WXFlatList/index.js b/packages/wx-react-native/miniprogram_dist/component/WXFlatList/index.js index 8270a88..a706cbc 100644 --- a/packages/wx-react-native/miniprogram_dist/component/WXFlatList/index.js +++ b/packages/wx-react-native/miniprogram_dist/component/WXFlatList/index.js @@ -13,7 +13,7 @@ const top = 80 Component({ properties: { diuu: null, - _r: null, + R: null, }, attached() { @@ -23,20 +23,17 @@ Component({ ready() { instanceManager.setWxCompInst(this.data.diuu, this) const compInst = instanceManager.getCompInstByUUID(this.data.diuu) - if (!compInst.firstRender) { - compInst.firstUpdateUI() - } this.compInst = compInst const method = getPropsMethod(this, 'onRefresh'); - this.hasOnRefreshPassed = !!this.data._r.onRefreshPassed + this.hasOnRefreshPassed = !!this.data.R.onRefreshPassed this.onRefreshMethod = method this.onScrollFunc = getPropsMethod(this, 'onScroll'); this.onScrollEndDragFunc = getPropsMethod(this, 'onScrollEndDrag'); this.hasChanges = [] - const infos = this.data._r.stickyInfos + const infos = this.data.R.stickyInfos if (Array.isArray(infos) && infos.length > 0) { for (let k = 0; k < infos.length; k++) { this.hasChanges.push(false) @@ -84,7 +81,9 @@ Component({ clearTimeout(this.stopTimerFlag) } this.stopTimerFlag = setTimeout(() => { - if (this.lastVal <= 80 && !this.data._r.refreshing) { + + const refreshing = (this.data._r || this.data.R).refreshing + if (this.lastVal <= 80 && !refreshing) { this.setData({ sr: false }); @@ -107,8 +106,9 @@ Component({ this.onScrollFunc(this.formatEvent(e)); } - if (this.data._r.stickyInfos) { - const infos = this.data._r.stickyInfos + const stickyInfos = (this.data._r || this.data.R).stickyInfos + if (stickyInfos) { + const infos = stickyInfos if (Array.isArray(infos) && infos.length > 0) { for (let k = 0; k < infos.length; k++) { const info = infos[k] @@ -155,7 +155,8 @@ Component({ return; } //松手归位 - if (this.lastVal <= top && this.lastVal >= 20 && !this.data._r.refreshing) { + const refreshing = (this.data._r || this.data.R).refreshing + if (this.lastVal <= top && this.lastVal >= 20 && !refreshing) { this.setData({ sr: false }); diff --git a/packages/wx-react-native/miniprogram_dist/component/WXFlatList/index.wxml b/packages/wx-react-native/miniprogram_dist/component/WXFlatList/index.wxml index 58834ad..f6e3799 100644 --- a/packages/wx-react-native/miniprogram_dist/component/WXFlatList/index.wxml +++ b/packages/wx-react-native/miniprogram_dist/component/WXFlatList/index.wxml @@ -14,82 +14,87 @@ ArrayContains : ArrayContains, } - - - - - + - - - \ No newline at end of file +