fix
parent
98240df7a3
commit
066c727e49
|
@ -31,18 +31,20 @@ export function cloneVNodes (vnodes, deep) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function cloneElement (node, nodeProps) {
|
export function cloneElement (node, nodeProps) {
|
||||||
const { props, key } = nodeProps
|
const { props = {}, key, on = {}} = nodeProps
|
||||||
if (node.componentOptions) {
|
if (node.componentOptions) {
|
||||||
node.componentOptions.propsData = node.componentOptions.propsData || {}
|
node.componentOptions.propsData = node.componentOptions.propsData || {}
|
||||||
|
node.componentOptions.listeners = node.componentOptions.listeners || {}
|
||||||
Object.assign(node.componentOptions.propsData, props)
|
Object.assign(node.componentOptions.propsData, props)
|
||||||
|
Object.assign(node.componentOptions.listeners, on)
|
||||||
}
|
}
|
||||||
|
|
||||||
const data = node.data || {}
|
const data = node.data || {}
|
||||||
const { style = data.style,
|
const { style = data.style,
|
||||||
class: cls = data.class,
|
class: cls = data.class,
|
||||||
attrs = data.attrs,
|
attrs = data.attrs,
|
||||||
on = data.on,
|
|
||||||
} = nodeProps
|
} = nodeProps
|
||||||
node.data = Object.assign(data, { style, attrs, class: cls, on })
|
node.data = Object.assign(data, { style, attrs, class: cls })
|
||||||
if (key !== undefined) {
|
if (key !== undefined) {
|
||||||
node.key = key
|
node.key = key
|
||||||
node.data.key = key
|
node.data.key = key
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
<script>
|
<script>
|
||||||
import { cloneElement } from '../../_util/vnode'
|
import { cloneElement } from '../../_util/vnode'
|
||||||
import Menu, { SubMenu, Item as MenuItem, Divider } from '../src/index'
|
import Menu, { SubMenu, Item as MenuItem, Divider } from '../src/index'
|
||||||
|
import { Icon } from 'antd'
|
||||||
import '../assets/index.less'
|
import '../assets/index.less'
|
||||||
import animate from 'css-animation'
|
import animate from 'css-animation'
|
||||||
|
|
||||||
|
@ -80,7 +81,10 @@ export default {
|
||||||
const commonMenu = (<Menu class='test' onSelect={handleSelect} onOpenChange={onOpenChange}>
|
const commonMenu = (<Menu class='test' onSelect={handleSelect} onOpenChange={onOpenChange}>
|
||||||
<SubMenu key='1'>
|
<SubMenu key='1'>
|
||||||
<template slot='title'><span>sub menu</span></template>
|
<template slot='title'><span>sub menu</span></template>
|
||||||
<MenuItem key='1-1'>0-1</MenuItem>
|
<MenuItem key='1-1'>
|
||||||
|
0-1
|
||||||
|
<Icon type='search'/>
|
||||||
|
</MenuItem>
|
||||||
<MenuItem key='1-2'>0-2</MenuItem>
|
<MenuItem key='1-2'>0-2</MenuItem>
|
||||||
</SubMenu>
|
</SubMenu>
|
||||||
</Menu>)
|
</Menu>)
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
import PropTypes from '../../_util/vue-types'
|
import PropTypes from '../../_util/vue-types'
|
||||||
import KeyCode from '../../_util/KeyCode'
|
import KeyCode from '../../_util/KeyCode'
|
||||||
import { noop } from './util'
|
import { noop } from './util'
|
||||||
|
import StateMixin from '../../_util/StateMixin'
|
||||||
|
|
||||||
const MenuItem = {
|
const MenuItem = {
|
||||||
name: 'MenuItem',
|
name: 'MenuItem',
|
||||||
|
@ -26,7 +27,7 @@ const MenuItem = {
|
||||||
// onMouseLeave: PropTypes.func,
|
// onMouseLeave: PropTypes.func,
|
||||||
clearSubMenuTimers: PropTypes.func.def(noop),
|
clearSubMenuTimers: PropTypes.func.def(noop),
|
||||||
},
|
},
|
||||||
|
mixins: [StateMixin],
|
||||||
beforeDestroy () {
|
beforeDestroy () {
|
||||||
const props = this.$props
|
const props = this.$props
|
||||||
this.$emit('destroy', props.eventKey)
|
this.$emit('destroy', props.eventKey)
|
||||||
|
|
|
@ -3,7 +3,6 @@ import hasProp from '../../_util/hasProp'
|
||||||
import KeyCode from '../../_util/KeyCode'
|
import KeyCode from '../../_util/KeyCode'
|
||||||
import scrollIntoView from 'dom-scroll-into-view'
|
import scrollIntoView from 'dom-scroll-into-view'
|
||||||
import { getKeyFromChildrenIndex, loopMenuItem } from './util'
|
import { getKeyFromChildrenIndex, loopMenuItem } from './util'
|
||||||
import StateMixin from '../../_util/StateMixin'
|
|
||||||
import { cloneElement, cloneVNode } from '../../_util/vnode'
|
import { cloneElement, cloneVNode } from '../../_util/vnode'
|
||||||
import DOMWrap from './DOMWrap'
|
import DOMWrap from './DOMWrap'
|
||||||
|
|
||||||
|
@ -62,7 +61,6 @@ export default {
|
||||||
openKeys: PropTypes.arrayOf(PropTypes.string),
|
openKeys: PropTypes.arrayOf(PropTypes.string),
|
||||||
mode: PropTypes.oneOf(['horizontal', 'vertical', 'vertical-left', 'vertical-right', 'inline']).def('vertical'),
|
mode: PropTypes.oneOf(['horizontal', 'vertical', 'vertical-left', 'vertical-right', 'inline']).def('vertical'),
|
||||||
},
|
},
|
||||||
mixin: [StateMixin],
|
|
||||||
data () {
|
data () {
|
||||||
const props = this.$props
|
const props = this.$props
|
||||||
return {
|
return {
|
||||||
|
@ -203,7 +201,7 @@ export default {
|
||||||
on: {
|
on: {
|
||||||
click: this.onClick,
|
click: this.onClick,
|
||||||
itemHover: this.onItemHover,
|
itemHover: this.onItemHover,
|
||||||
openChange: () => { console.log('openChange') },
|
openChange: this.onOpenChange,
|
||||||
deselect: this.onDeselect,
|
deselect: this.onDeselect,
|
||||||
destroy: this.onDestroy,
|
destroy: this.onDestroy,
|
||||||
select: this.onSelect,
|
select: this.onSelect,
|
||||||
|
@ -219,7 +217,6 @@ export default {
|
||||||
if (!extraProps.isRootMenu) {
|
if (!extraProps.isRootMenu) {
|
||||||
newChildProps.props.clearSubMenuTimers = this.clearSubMenuTimers
|
newChildProps.props.clearSubMenuTimers = this.clearSubMenuTimers
|
||||||
}
|
}
|
||||||
// return this.$scopedSlots.default(newChildProps)
|
|
||||||
return cloneElement(child, newChildProps)
|
return cloneElement(child, newChildProps)
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -252,11 +249,11 @@ export default {
|
||||||
}
|
}
|
||||||
const newChildren = children.map(this.renderMenuItem)
|
const newChildren = children.map(this.renderMenuItem)
|
||||||
return (
|
return (
|
||||||
<DOMWrap
|
<ul
|
||||||
{...domProps}
|
{...domProps}
|
||||||
>
|
>
|
||||||
{newChildren}
|
{newChildren}
|
||||||
</DOMWrap>
|
</ul>
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -52,14 +52,6 @@ export default {
|
||||||
isSubMenu: 1,
|
isSubMenu: 1,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
|
||||||
'$props': {
|
|
||||||
handler: function (nextProps) {
|
|
||||||
console.log(nextProps)
|
|
||||||
},
|
|
||||||
deep: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
mounted () {
|
mounted () {
|
||||||
this.handleUpdated()
|
this.handleUpdated()
|
||||||
},
|
},
|
||||||
|
@ -139,7 +131,6 @@ export default {
|
||||||
|
|
||||||
onOpenChange (e) {
|
onOpenChange (e) {
|
||||||
this.$emit('openChange', e)
|
this.$emit('openChange', e)
|
||||||
this.$props.openChange(e)
|
|
||||||
},
|
},
|
||||||
|
|
||||||
onPopupVisibleChange (visible) {
|
onPopupVisibleChange (visible) {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
<script>
|
<script>
|
||||||
import PropTypes from '../../_util/vue-types'
|
import PropTypes from '../../_util/vue-types'
|
||||||
import MenuMixin from './MenuMixin'
|
import MenuMixin from './MenuMixin'
|
||||||
|
import StateMixin from '../../_util/StateMixin'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'SubPopupMenu',
|
name: 'SubPopupMenu',
|
||||||
|
@ -16,7 +17,7 @@ export default {
|
||||||
visible: PropTypes.bool,
|
visible: PropTypes.bool,
|
||||||
},
|
},
|
||||||
|
|
||||||
mixins: [MenuMixin],
|
mixins: [MenuMixin, StateMixin],
|
||||||
methods: {
|
methods: {
|
||||||
onDeselect (selectInfo) {
|
onDeselect (selectInfo) {
|
||||||
this.$emit('deselect', selectInfo)
|
this.$emit('deselect', selectInfo)
|
||||||
|
|
Loading…
Reference in New Issue