小程序源码
This commit is contained in:
50
source/wx/xzs-student/component/iView/grid/index.js
Normal file
50
source/wx/xzs-student/component/iView/grid/index.js
Normal file
@@ -0,0 +1,50 @@
|
||||
Component({
|
||||
externalClasses: ['i-class'],
|
||||
|
||||
relations: {
|
||||
'../grid-item/index': {
|
||||
type: 'child',
|
||||
linked () {
|
||||
this.setGridItemWidth();
|
||||
},
|
||||
linkChanged () {
|
||||
this.setGridItemWidth();
|
||||
},
|
||||
unlinked () {
|
||||
this.setGridItemWidth();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
setGridItemWidth () {
|
||||
const nodes = this.getRelationNodes('../grid-item/index');
|
||||
|
||||
// const len = nodes.length;
|
||||
// if (len < 3) {
|
||||
// nodes.forEach(item => {
|
||||
// item.setData({
|
||||
// 'width': '33.33%'
|
||||
// });
|
||||
// });
|
||||
// } else {
|
||||
// const width = 100 / nodes.length;
|
||||
// nodes.forEach(item => {
|
||||
// item.setData({
|
||||
// 'width': width + '%'
|
||||
// });
|
||||
// });
|
||||
// }
|
||||
const width = 100 / nodes.length;
|
||||
nodes.forEach(item => {
|
||||
item.setData({
|
||||
'width': width + '%'
|
||||
});
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
ready () {
|
||||
this.setGridItemWidth();
|
||||
}
|
||||
});
|
||||
3
source/wx/xzs-student/component/iView/grid/index.json
Normal file
3
source/wx/xzs-student/component/iView/grid/index.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"component": true
|
||||
}
|
||||
1
source/wx/xzs-student/component/iView/grid/index.wxml
Normal file
1
source/wx/xzs-student/component/iView/grid/index.wxml
Normal file
@@ -0,0 +1 @@
|
||||
<view class="i-class i-grid"><slot></slot></view>
|
||||
1
source/wx/xzs-student/component/iView/grid/index.wxss
Normal file
1
source/wx/xzs-student/component/iView/grid/index.wxss
Normal file
@@ -0,0 +1 @@
|
||||
.i-grid{border-top:1rpx solid #e9eaec;border-left:1rpx solid #e9eaec;overflow:hidden}
|
||||
Reference in New Issue
Block a user