Item.vue 681 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  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 {
  22. vnodes.push(<svg-icon icon-class={icon} />)
  23. }
  24. }
  25. if (title) {
  26. vnodes.push(<span slot="title">{title}</span>)
  27. }
  28. return vnodes
  29. }
  30. }
  31. </script>
  32. <style scoped>
  33. .sub-el-icon {
  34. color: currentColor;
  35. width: 1em;
  36. height: 1em;
  37. }
  38. </style>