Blame view

HHECS.Web/src/layout/components/Sidebar/Item.vue 692 Bytes
胡菁 authored
1
2
<script>
export default {
胡菁 authored
3
  name: "MenuItem",
胡菁 authored
4
5
6
7
  functional: true,
  props: {
    icon: {
      type: String,
胡菁 authored
8
      default: "",
胡菁 authored
9
10
11
    },
    title: {
      type: String,
胡菁 authored
12
13
      default: "",
    },
胡菁 authored
14
15
  },
  render(h, context) {
胡菁 authored
16
17
    const { icon, title } = context.props;
    const vnodes = [];
胡菁 authored
18
19

    if (icon) {
胡菁 authored
20
21
      if (icon.includes("el-icon")) {
        vnodes.push(<i class={[icon, "sub-el-icon"]} />);
胡菁 authored
22
      } else {
胡菁 authored
23
        vnodes.push(<svg-icon icon-class={icon} />);
胡菁 authored
24
25
26
27
      }
    }

    if (title) {
胡菁 authored
28
      vnodes.push(<span slot="title">{title}</span>);
胡菁 authored
29
    }
胡菁 authored
30
31
32
    return vnodes;
  },
};
胡菁 authored
33
34
35
36
37
38
39
40
41
</script>

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