采用 findComponentUpward 替代 this.$parent.$parent.$parent 获取 Dropdown 父节点组件

This commit is contained in:
BillyWang 2018-03-28 22:47:10 +08:00
parent d45d2ee061
commit 9b7e32b507

View file

@ -3,7 +3,7 @@
</template>
<script>
const prefixCls = 'ivu-dropdown-item';
import { findComponentUpward } from '../../utils/assist';
export default {
name: 'DropdownItem',
props: {
@ -37,7 +37,7 @@
},
methods: {
handleClick () {
const $parent = this.$parent.$parent.$parent;
const $parent = findComponentUpward(this, 'Dropdown');
const hasChildren = this.$parent && this.$parent.$options.name === 'Dropdown';
if (this.disabled) {