Item.vue 682 Bytes
Newer Older
1 2 3 4 5
<script>
export default {
  name: 'MenuItem',
  functional: true,
  props: {
花裤衩's avatar
花裤衩 committed
6 7 8 9 10 11 12
    icon: {
      type: String,
      default: ''
    },
    title: {
      type: String,
      default: ''
13 14 15
    }
  },
  render(h, context) {
花裤衩's avatar
花裤衩 committed
16
    const { icon, title } = context.props
17 18 19
    const vnodes = []

    if (icon) {
20 21 22 23 24
      if (icon.includes('el-icon')) {
        vnodes.push(<i class={[icon, 'sub-el-icon']} />)
      } else {
        vnodes.push(<svg-icon icon-class={icon}/>)
      }
25 26 27 28 29 30 31 32 33
    }

    if (title) {
      vnodes.push(<span slot='title'>{(title)}</span>)
    }
    return vnodes
  }
}
</script>
34 35 36 37 38 39 40 41

<style scoped>
.sub-el-icon {
  color: currentColor;
  width: 1em;
  height: 1em;
}
</style>