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