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

View file

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

View file

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