Commit ce7b39c204d3a496d695bc9a49d7c8c6ade33f30

Authored by 梁灏
1 parent 679b2a2b

fixed #3596

Showing 2 changed files with 7 additions and 4 deletions   Show diff stats
src/components/grid/row.vue
@@ -4,7 +4,7 @@ @@ -4,7 +4,7 @@
4 </div> 4 </div>
5 </template> 5 </template>
6 <script> 6 <script>
7 - import { oneOf, findComponentsDownward } from '../../utils/assist'; 7 + import { oneOf, findComponentDownward, findBrothersComponents } from '../../utils/assist';
8 8
9 const prefixCls = 'ivu-row'; 9 const prefixCls = 'ivu-row';
10 10
@@ -58,7 +58,10 @@ @@ -58,7 +58,10 @@
58 }, 58 },
59 methods: { 59 methods: {
60 updateGutter (val) { 60 updateGutter (val) {
61 - const Cols = findComponentsDownward(this, 'iCol'); 61 + // 这里会嵌套寻找,把 Col 里的 Row 里的 Col 也找到,所以用 兄弟找
  62 +// const Cols = findComponentsDownward(this, 'iCol');
  63 + const Col = findComponentDownward(this, 'iCol');
  64 + const Cols = findBrothersComponents(Col, 'iCol', false);
62 if (Cols.length) { 65 if (Cols.length) {
63 Cols.forEach((child) => { 66 Cols.forEach((child) => {
64 if (val !== 0) { 67 if (val !== 0) {
src/utils/assist.js
@@ -230,12 +230,12 @@ export function findComponentsUpward (context, componentName) { @@ -230,12 +230,12 @@ export function findComponentsUpward (context, componentName) {
230 } 230 }
231 231
232 // Find brothers components 232 // Find brothers components
233 -export function findBrothersComponents (context, componentName) { 233 +export function findBrothersComponents (context, componentName, exceptMe = true) {
234 let res = context.$parent.$children.filter(item => { 234 let res = context.$parent.$children.filter(item => {
235 return item.$options.name === componentName; 235 return item.$options.name === componentName;
236 }); 236 });
237 let index = res.indexOf(context); 237 let index = res.indexOf(context);
238 - res.splice(index, 1); 238 + if (exceptMe) res.splice(index, 1);
239 return res; 239 return res;
240 } 240 }
241 241