This commit is contained in:
梁灏 2017-08-24 15:06:54 +08:00
parent b9541c05ca
commit 9eec7f1660
3 changed files with 31 additions and 14 deletions

View file

@ -1,16 +1,26 @@
<style> <style>
.demo-col div{ .ivu-col div{
background: #f50; background: rgba(0,153,229,.7);
} }
</style> </style>
<template> <template>
<div> <div>
<Row :gutter="16"> <Row :gutter="64">
<i-col class-name="demo-col" span="4" v-for="i in n" key="i"> <Card>
<div>col-8</div> <i-col span="6">
</i-col> <div>col-6</div>
</i-col>
<i-col span="6">
<div>col-6</div>
</i-col>
<i-col span="6">
<div>col-6</div>
</i-col>
<i-col span="6">
<div>col-6</div>
</i-col>
</Card>
</Row> </Row>
<Button @click="add">add</Button>
</div> </div>
</template> </template>
<script> <script>

View file

@ -4,6 +4,7 @@
</div> </div>
</template> </template>
<script> <script>
import { findComponentUpward } from '../../utils/assist';
const prefixCls = 'ivu-col'; const prefixCls = 'ivu-col';
export default { export default {
@ -70,7 +71,10 @@
}, },
methods: { methods: {
updateGutter () { updateGutter () {
this.$parent.updateGutter(this.$parent.gutter); const Row = findComponentUpward(this, 'Row');
if (Row) {
Row.updateGutter(Row.gutter);
}
} }
}, },
mounted () { mounted () {

View file

@ -4,7 +4,7 @@
</div> </div>
</template> </template>
<script> <script>
import { oneOf } from '../../utils/assist'; import { oneOf, findComponentsDownward } from '../../utils/assist';
const prefixCls = 'ivu-row'; const prefixCls = 'ivu-row';
@ -58,11 +58,14 @@
}, },
methods: { methods: {
updateGutter (val) { updateGutter (val) {
this.$children.forEach((child) => { const Cols = findComponentsDownward(this, 'iCol');
if (val !== 0) { if (Cols.length) {
child.gutter = val; Cols.forEach((child) => {
} if (val !== 0) {
}); child.gutter = val;
}
});
}
} }
}, },
watch: { watch: {