ly-icon.vue 832 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <template>
  2. <i class="icon" :class="[name]" :style="[fontStyle]"></i>
  3. </template>
  4. <script>
  5. export default {
  6. props: {
  7. name: String,
  8. // 字体大小
  9. size: {
  10. type: [Number, String],
  11. default: ''
  12. },
  13. color: {
  14. type: String,
  15. default: ''
  16. }
  17. },
  18. data() {
  19. return {
  20. // fontStyle:{}
  21. }
  22. },
  23. onLoad() {
  24. // if (this.size) this.fontStyle.fontSize = this.size + uni.$u.config.unit
  25. // if (this.color) this.fontStyle.color = this.color
  26. },
  27. computed: {
  28. fontStyle() {
  29. const style = {}
  30. if (this.size) style.fontSize = this.size + uni.$u.config.unit
  31. if (this.color) style.color = this.color
  32. return style
  33. },
  34. },
  35. beforeCreate() {
  36. },
  37. methods: {
  38. onClick() {
  39. this.$emit('click')
  40. }
  41. },
  42. }
  43. </script>
  44. <style scoped>
  45. </style>