Merge pull request #3254 from xiaofengsha/pr002

采用 findComponentUpward 替代 this.$parent.$parent.$parent 获取 Dropdown 父节点组件
This commit is contained in:
Aresn 2018-04-02 10:56:43 +08:00 committed by GitHub
commit a1a1e0c73e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

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) {