Commit a1a1e0c73eb30095536521cf2c3ff6f8ef3f36c4
Committed by
GitHub
Merge pull request #3254 from xiaofengsha/pr002
采用 findComponentUpward 替代 this.$parent.$parent.$parent 获取 Dropdown 父节点组件
Showing
1 changed file
with
2 additions
and
2 deletions
Show diff stats
src/components/dropdown/dropdown-item.vue
@@ -3,7 +3,7 @@ | @@ -3,7 +3,7 @@ | ||
3 | </template> | 3 | </template> |
4 | <script> | 4 | <script> |
5 | const prefixCls = 'ivu-dropdown-item'; | 5 | const prefixCls = 'ivu-dropdown-item'; |
6 | - | 6 | + import { findComponentUpward } from '../../utils/assist'; |
7 | export default { | 7 | export default { |
8 | name: 'DropdownItem', | 8 | name: 'DropdownItem', |
9 | props: { | 9 | props: { |
@@ -37,7 +37,7 @@ | @@ -37,7 +37,7 @@ | ||
37 | }, | 37 | }, |
38 | methods: { | 38 | methods: { |
39 | handleClick () { | 39 | handleClick () { |
40 | - const $parent = this.$parent.$parent.$parent; | 40 | + const $parent = findComponentUpward(this, 'Dropdown'); |
41 | const hasChildren = this.$parent && this.$parent.$options.name === 'Dropdown'; | 41 | const hasChildren = this.$parent && this.$parent.$options.name === 'Dropdown'; |
42 | 42 | ||
43 | if (this.disabled) { | 43 | if (this.disabled) { |