liweilong
2020-10-30 2a61f64ebeeec3fff23b7adbce8c7fbfc54add51
提交 | 用户 | age
2a61f6 1 <script>
L 2 export default {
3   name: 'MenuItem',
4   functional: true,
5   props: {
6     icon: {
7       type: String,
8       default: ''
9     },
10     title: {
11       type: String,
12       default: ''
13     }
14   },
15   render(h, context) {
16     const { icon, title } = context.props
17     const vnodes = []
18
19     if (icon) {
20       if (icon.includes('el-icon')) {
21         vnodes.push(<i class={[icon, 'sub-el-icon']} />)
22       } else {
23         vnodes.push(<svg-icon icon-class={icon}/>)
24       }
25     }
26
27     if (title) {
28       vnodes.push(<span slot='title'>{(title)}</span>)
29     }
30     return vnodes
31   }
32 }
33 </script>
34
35 <style scoped>
36 .sub-el-icon {
37   color: currentColor;
38   width: 1em;
39   height: 1em;
40 }
41 </style>