Commit acba45fed5adf8d6a21204150efabfbfbddd0f2c
1 parent
a163daa0
move computed value parentSubmenuNum from .vue to mixin.js
Showing
3 changed files
with
14 additions
and
10 deletions
Show diff stats
src/components/menu/menu-item.vue
... | ... | @@ -3,12 +3,13 @@ |
3 | 3 | </template> |
4 | 4 | <script> |
5 | 5 | import Emitter from '../../mixins/emitter'; |
6 | - import { findComponentUpward, findComponentsUpward } from '../../utils/assist'; | |
6 | + import { findComponentUpward } from '../../utils/assist'; | |
7 | 7 | const prefixCls = 'ivu-menu'; |
8 | + import mixin from './mixin'; | |
8 | 9 | |
9 | 10 | export default { |
10 | 11 | name: 'MenuItem', |
11 | - mixins: [ Emitter ], | |
12 | + mixins: [ Emitter, mixin ], | |
12 | 13 | props: { |
13 | 14 | name: { |
14 | 15 | type: [String, Number], |
... | ... | @@ -35,9 +36,6 @@ |
35 | 36 | } |
36 | 37 | ]; |
37 | 38 | }, |
38 | - parentSubmenuNum () { | |
39 | - return findComponentsUpward(this, 'Submenu').length; | |
40 | - }, | |
41 | 39 | itemStyle () { |
42 | 40 | return this.hasParentSubmenu ? { |
43 | 41 | paddingLeft: 43 + (this.parentSubmenuNum - 1) * 24 + 'px' | ... | ... |
src/components/menu/submenu.vue
... | ... | @@ -21,14 +21,15 @@ |
21 | 21 | import Drop from '../select/dropdown.vue'; |
22 | 22 | import Icon from '../icon/icon.vue'; |
23 | 23 | import CollapseTransition from '../base/collapse-transition'; |
24 | - import { getStyle, findComponentUpward, findComponentsUpward, findComponentsDownward } from '../../utils/assist'; | |
24 | + import { getStyle, findComponentUpward, findComponentsDownward } from '../../utils/assist'; | |
25 | 25 | import Emitter from '../../mixins/emitter'; |
26 | + import mixin from './mixin'; | |
26 | 27 | |
27 | 28 | const prefixCls = 'ivu-menu'; |
28 | 29 | |
29 | 30 | export default { |
30 | 31 | name: 'Submenu', |
31 | - mixins: [ Emitter ], | |
32 | + mixins: [ Emitter, mixin ], | |
32 | 33 | components: { Icon, Drop, CollapseTransition }, |
33 | 34 | props: { |
34 | 35 | name: { |
... | ... | @@ -77,9 +78,6 @@ |
77 | 78 | hasParentSubmenu () { |
78 | 79 | return findComponentUpward(this, 'Submenu'); |
79 | 80 | }, |
80 | - parentSubmenuNum () { | |
81 | - return findComponentsUpward(this, 'Submenu').length; | |
82 | - }, | |
83 | 81 | titleStyle () { |
84 | 82 | return this.hasParentSubmenu ? { |
85 | 83 | paddingLeft: 43 + (this.parentSubmenuNum - 1) * 24 + 'px' | ... | ... |