Skip to content

Commit 4435d56

Browse files
张寸起7insummer
authored andcommitted
fix:修复water-flow组件在数据为[]是不刷新的问题(#572
1 parent c2b756b commit 4435d56

File tree

6 files changed

+12
-9
lines changed

6 files changed

+12
-9
lines changed

dist/water-flow/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ Component({
3838
console.error('[data]参数类型错误,渲染失败');
3939
return false;
4040
}
41+
// 绑定data,判断data是否为[]
42+
this.setData({ data });
4143
if (refresh) {
4244
this.data.leftData = [];
4345
this.data.rightData = [];
@@ -50,15 +52,14 @@ Component({
5052
_select(data, refresh) {
5153
const query = wx.createSelectorQuery().in(this);
5254
this.columnNodes = query.selectAll('#left, #right');
53-
5455
return new Promise((resolve) => {
5556
this._render(data, 0, refresh, () => {
5657
resolve();
5758
});
5859
});
5960
},
6061
_render(data, i, refresh, success) {
61-
if (data.length > i) {
62+
if ((data.length > i || refresh) && this.data.data.length !== 0) {
6263
this.columnNodes.boundingClientRect().exec(res => {
6364
const rects = res[0];
6465
this.data.leftHeight = rects[0].height;

dist/water-flow/index.wxml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<view class="l-class water-flow-container">
1+
<view class="l-class water-flow-container" wx:if="{{data.length!==0}}" >
22
<view class="water-column" style="margin-right:{{columnGap}}">
33
<view id="left">
44
<block wx:for="{{leftData}}" wx:key="{{index}}">

examples/dist/water-flow/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ Component({
3838
console.error('[data]参数类型错误,渲染失败');
3939
return false;
4040
}
41+
// 绑定data,判断data是否为[]
42+
this.setData({ data });
4143
if (refresh) {
4244
this.data.leftData = [];
4345
this.data.rightData = [];
@@ -50,15 +52,14 @@ Component({
5052
_select(data, refresh) {
5153
const query = wx.createSelectorQuery().in(this);
5254
this.columnNodes = query.selectAll('#left, #right');
53-
5455
return new Promise((resolve) => {
5556
this._render(data, 0, refresh, () => {
5657
resolve();
5758
});
5859
});
5960
},
6061
_render(data, i, refresh, success) {
61-
if (data.length > i) {
62+
if ((data.length > i || refresh) && this.data.data.length !== 0) {
6263
this.columnNodes.boundingClientRect().exec(res => {
6364
const rects = res[0];
6465
this.data.leftHeight = rects[0].height;

examples/dist/water-flow/index.wxml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<view class="l-class water-flow-container">
1+
<view class="l-class water-flow-container" wx:if="{{data.length!==0}}" >
22
<view class="water-column" style="margin-right:{{columnGap}}">
33
<view id="left">
44
<block wx:for="{{leftData}}" wx:key="{{index}}">

src/water-flow/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ Component({
3838
console.error('[data]参数类型错误,渲染失败');
3939
return false;
4040
}
41+
// 绑定data,判断data是否为[]
42+
this.setData({ data });
4143
if (refresh) {
4244
this.data.leftData = [];
4345
this.data.rightData = [];
@@ -50,15 +52,14 @@ Component({
5052
_select(data, refresh) {
5153
const query = wx.createSelectorQuery().in(this);
5254
this.columnNodes = query.selectAll('#left, #right');
53-
5455
return new Promise((resolve) => {
5556
this._render(data, 0, refresh, () => {
5657
resolve();
5758
});
5859
});
5960
},
6061
_render(data, i, refresh, success) {
61-
if (data.length > i) {
62+
if ((data.length > i || refresh) && this.data.data.length !== 0) {
6263
this.columnNodes.boundingClientRect().exec(res => {
6364
const rects = res[0];
6465
this.data.leftHeight = rects[0].height;

src/water-flow/index.wxml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<view class="l-class water-flow-container">
1+
<view class="l-class water-flow-container" wx:if="{{data.length!==0}}" >
22
<view class="water-column" style="margin-right:{{columnGap}}">
33
<view id="left">
44
<block wx:for="{{leftData}}" wx:key="{{index}}">

0 commit comments

Comments
 (0)