Commit ce7b39c204d3a496d695bc9a49d7c8c6ade33f30
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 | 4 | </div> |
| 5 | 5 | </template> |
| 6 | 6 | <script> |
| 7 | - import { oneOf, findComponentsDownward } from '../../utils/assist'; | |
| 7 | + import { oneOf, findComponentDownward, findBrothersComponents } from '../../utils/assist'; | |
| 8 | 8 | |
| 9 | 9 | const prefixCls = 'ivu-row'; |
| 10 | 10 | |
| ... | ... | @@ -58,7 +58,10 @@ |
| 58 | 58 | }, |
| 59 | 59 | methods: { |
| 60 | 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 | 65 | if (Cols.length) { |
| 63 | 66 | Cols.forEach((child) => { |
| 64 | 67 | if (val !== 0) { | ... | ... |
src/utils/assist.js
| ... | ... | @@ -230,12 +230,12 @@ export function findComponentsUpward (context, componentName) { |
| 230 | 230 | } |
| 231 | 231 | |
| 232 | 232 | // Find brothers components |
| 233 | -export function findBrothersComponents (context, componentName) { | |
| 233 | +export function findBrothersComponents (context, componentName, exceptMe = true) { | |
| 234 | 234 | let res = context.$parent.$children.filter(item => { |
| 235 | 235 | return item.$options.name === componentName; |
| 236 | 236 | }); |
| 237 | 237 | let index = res.indexOf(context); |
| 238 | - res.splice(index, 1); | |
| 238 | + if (exceptMe) res.splice(index, 1); | |
| 239 | 239 | return res; |
| 240 | 240 | } |
| 241 | 241 | ... | ... |