Blame view

src/layout/components/Sidebar/Item.vue 729 Bytes
be966eff   jack   1.添加文件
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
  <script>
  export default {
    name: 'MenuItem',
    functional: true,
    props: {
      icon: {
        type: String,
        default: ''
      },
      title: {
        type: String,
        default: ''
      }
    },
    render(h, context) {
      const { icon, title } = context.props
      const vnodes = []
  
      if (icon) {
        /** 图标分为svg和element自带的两种,主要通过classname区分,带el-的为自带的图标,所以后期如果需要添加svg图标,注意名字不要带el- */
        icon.includes('el-')
          ? vnodes.push(<i class={icon}></i>)
          : vnodes.push(<svg-icon icon-class={icon} />)
      }
  
      if (title) {
        vnodes.push(<span slot='title'>{title}</span>)
      }
      return vnodes
    }
  }
  </script>