修复使用全局变量,导致部分cell边框不出现的问题 (#237)

This commit is contained in:
Yao 2018-05-11 14:44:05 +08:00 committed by GitHub
parent 6d771e7338
commit 026813e4ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 10 deletions

View File

@ -2,7 +2,8 @@ var Zan = require('../../dist/index');
Page(Object.assign({}, Zan.Switch, {
data: {
checked: false
checked: false,
show: true
},
onLoad() {

View File

@ -31,10 +31,12 @@
<zan-cell title="只显示箭头" is-link></zan-cell>
<zan-cell title="跳转到首页" is-link url="/pages/dashboard/index"></zan-cell>
<zan-cell title="只有 footer 点击有效" is-link url="/pages/dashboard/index" only-tap-footer></zan-cell>
<block wx:if="{{ show }}">
<zan-cell title="单行列表" label="附加描述" value="详细信息"></zan-cell>
<zan-cell title="表单">
<input slot="footer" type="digit" placeholder="带小数点的数字键盘"/>
</zan-cell>
</block>
<zan-cell title="开关">
<switch slot="footer" checked/>
</zan-cell>

View File

@ -1,5 +1,3 @@
let cellUpdateTimeout = 0;
Component({
relations: {
'../cell/index': {
@ -16,15 +14,19 @@ Component({
}
},
data: {
cellUpdateTimeout: 0
},
methods: {
_updateIsLastCell() {
// 用 setTimeout 减少计算次数
if (cellUpdateTimeout > 0) {
if (this.data.cellUpdateTimeout > 0) {
return;
}
cellUpdateTimeout = setTimeout(() => {
cellUpdateTimeout = 0;
const cellUpdateTimeout = setTimeout(() => {
this.setData({ cellUpdateTimeout: 0 });
let cells = this.getRelationNodes('../cell/index');
if (cells.length > 0) {
@ -35,6 +37,8 @@ Component({
});
}
});
this.setData({ cellUpdateTimeout });
}
}
});