小程序源码
This commit is contained in:
33
source/wx/xzs-student/component/iView/cell-group/index.js
Normal file
33
source/wx/xzs-student/component/iView/cell-group/index.js
Normal file
@@ -0,0 +1,33 @@
|
||||
Component({
|
||||
externalClasses: ['i-class'],
|
||||
|
||||
relations: {
|
||||
'../cell/index': {
|
||||
type: 'child',
|
||||
linked () {
|
||||
this._updateIsLastCell();
|
||||
},
|
||||
linkChanged () {
|
||||
this._updateIsLastCell();
|
||||
},
|
||||
unlinked () {
|
||||
this._updateIsLastCell();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
_updateIsLastCell() {
|
||||
let cells = this.getRelationNodes('../cell/index');
|
||||
const len = cells.length;
|
||||
|
||||
if (len > 0) {
|
||||
let lastIndex = len - 1;
|
||||
|
||||
cells.forEach((cell, index) => {
|
||||
cell.updateIsLastCell(index === lastIndex);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"component": true
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
<view class="i-class i-cell-group">
|
||||
<slot></slot>
|
||||
</view>
|
||||
Reference in New Issue
Block a user