Item.vue 819 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <script>
  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. if (icon) {
  19. if (icon.includes('el-icon')) {
  20. vnodes.push(<i class={[icon, 'sub-el-icon']} />)
  21. } else if (icon.includes('icon-common')) {
  22. vnodes.push(<i class={[icon, 'icon', 'iconfont']} style='margin-right: 5px' />)
  23. } else {
  24. vnodes.push(<svg-icon icon-class={icon}/>)
  25. }
  26. }
  27. if (title) {
  28. vnodes.push(<span slot='title'>{(title)}</span>)
  29. }
  30. return vnodes
  31. }
  32. }
  33. </script>
  34. <style scoped>
  35. .sub-el-icon {
  36. color: currentColor;
  37. width: 1em;
  38. height: 1em;
  39. }
  40. </style>