mirror of
https://gitee.com/ant-design-vue/ant-design-vue.git
synced 2024-12-03 04:27:41 +08:00
44 lines
1.0 KiB
Vue
44 lines
1.0 KiB
Vue
|
|
import { Item, itemProps } from '../vc-menu'
|
|
import { getOptionProps } from '../_util/props-util'
|
|
import Tooltip from '../tooltip'
|
|
function noop () {}
|
|
export default {
|
|
props: itemProps,
|
|
name: 'MenuItem',
|
|
inject: {
|
|
getInlineCollapsed: { default: () => noop },
|
|
},
|
|
isMenuItem: 1,
|
|
methods: {
|
|
onKeyDown (e) {
|
|
this.$refs.menuItem.onKeyDown(e)
|
|
},
|
|
},
|
|
render (h) {
|
|
const props = getOptionProps(this)
|
|
const { getInlineCollapsed, $slots, $attrs: attrs, $listeners } = this
|
|
const inlineCollapsed = getInlineCollapsed()
|
|
const itemProps = {
|
|
props,
|
|
attrs,
|
|
on: $listeners,
|
|
}
|
|
const toolTipProps = {
|
|
props: {
|
|
title: inlineCollapsed && props.level === 1 ? $slots.default : '',
|
|
placement: 'right',
|
|
overlayClassName: `${props.rootPrefixCls}-inline-collapsed-tooltip`,
|
|
},
|
|
}
|
|
return (
|
|
<Tooltip {...toolTipProps}>
|
|
<Item {...itemProps} ref='menuItem'>
|
|
{$slots.default}
|
|
</Item>
|
|
</Tooltip>
|
|
)
|
|
},
|
|
}
|
|
|