ant-design-vue/components/vc-menu/MenuItemGroup.vue

46 lines
1.2 KiB
Vue
Raw Normal View History

2017-12-12 05:49:02 +00:00
<script>
2018-02-06 09:22:36 +00:00
import PropTypes from '../_util/vue-types'
import { getComponentFromProp } from '../_util/props-util'
2017-12-12 05:49:02 +00:00
const MenuItemGroup = {
name: 'MenuItemGroup',
props: {
renderMenuItem: PropTypes.func,
index: PropTypes.number,
className: PropTypes.string,
rootPrefixCls: PropTypes.string,
disabled: PropTypes.bool.def(true),
2018-01-19 10:01:43 +00:00
title: PropTypes.any,
2017-12-12 05:49:02 +00:00
},
2018-01-04 11:06:54 +00:00
isMenuItemGroup: true,
2017-12-12 05:49:02 +00:00
methods: {
renderInnerMenuItem (item, subIndex) {
const { renderMenuItem, index } = this.$props
return renderMenuItem(item, index, subIndex)
},
},
render () {
const props = this.$props
const { rootPrefixCls } = props
const titleClassName = `${rootPrefixCls}-item-group-title`
const listClassName = `${rootPrefixCls}-item-group-list`
return (
<li class={`${rootPrefixCls}-item-group`}>
<div
class={titleClassName}
title={typeof props.title === 'string' ? props.title : undefined}
>
2018-01-19 10:01:43 +00:00
{getComponentFromProp(this, 'title')}
2017-12-12 05:49:02 +00:00
</div>
<ul class={listClassName}>
{this.$slots.default.map(this.renderInnerMenuItem)}
</ul>
</li>
)
},
}
export default MenuItemGroup
</script>