优化菜单名称过长悬停显示标题
This commit is contained in:
@ -1,29 +1,38 @@
|
|||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
name: 'MenuItem',
|
name: "MenuItem",
|
||||||
functional: true,
|
functional: true,
|
||||||
props: {
|
props: {
|
||||||
icon: {
|
icon: {
|
||||||
type: String,
|
type: String,
|
||||||
default: ''
|
default: "",
|
||||||
},
|
},
|
||||||
title: {
|
title: {
|
||||||
type: String,
|
type: String,
|
||||||
default: ''
|
default: "",
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
render(h, context) {
|
render(h, context) {
|
||||||
const { icon, title } = context.props
|
const { icon, title } = context.props;
|
||||||
const vnodes = []
|
const vnodes = [];
|
||||||
|
|
||||||
if (icon) {
|
if (icon) {
|
||||||
vnodes.push(<svg-icon icon-class={icon}/>)
|
vnodes.push(<svg-icon icon-class={icon} />);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (title) {
|
if (title) {
|
||||||
vnodes.push(<span slot='title'>{(title)}</span>)
|
// vnodes.push(<span slot="title">{title}</span>);
|
||||||
|
if (title.length > 6) {
|
||||||
|
vnodes.push(
|
||||||
|
<span slot="title" title={title}>
|
||||||
|
{title}
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
vnodes.push(<span slot="title">{title}</span>);
|
||||||
}
|
}
|
||||||
return vnodes
|
|
||||||
}
|
}
|
||||||
}
|
return vnodes;
|
||||||
|
},
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
Reference in New Issue
Block a user