lv-icon.vue 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <template>
  2. <i class="iconfont" :class="[type ? 'icon-' + type : '']" :style="styleObject"></i>
  3. </template>
  4. <script function>
  5. export default {
  6. name: 'lv-icon',
  7. data () {
  8. return {
  9. styleObject: {}
  10. }
  11. },
  12. props: {
  13. type: {
  14. type: String,
  15. default: ''
  16. },
  17. color: {
  18. type: String,
  19. default: ''
  20. },
  21. fontSize: {
  22. type: Number,
  23. default: 12
  24. },
  25. fontUnit: {
  26. type: String,
  27. default: 'px'
  28. }
  29. },
  30. watch: {
  31. fontSize(newSize) {
  32. if (newSize) this.$set(this.styleObject, 'font-size', this.fontSize + this.fontUnit);
  33. },
  34. color(newColor) {
  35. if (newColor) this.$set(this.styleObject, 'color', this.color);
  36. }
  37. },
  38. mounted() {
  39. if (this.color) {
  40. this.$set(this.styleObject, 'color', this.color);
  41. }
  42. if (this.fontSize) {
  43. this.$set(this.styleObject, 'font-size', this.fontSize + this.fontUnit);
  44. }
  45. }
  46. }
  47. </script>
  48. <style lang="less" scope>
  49. @font-face {
  50. font-family: "iconfont"; /* Project id 2760070 */
  51. src: url('../../assets/font/iconfont.woff2?t=1629537928872') format('woff2'),
  52. url('../../assets/font/iconfont.woff?t=1629537928872') format('woff'),
  53. url('../../assets/font/iconfont.ttf?t=1629537928872') format('truetype');
  54. }
  55. .iconfont {
  56. font-family: "iconfont" !important;
  57. font-size: 16px;
  58. font-style: normal;
  59. -webkit-font-smoothing: antialiased;
  60. -moz-osx-font-smoothing: grayscale;
  61. }
  62. .icon-add:before {
  63. content: "\e600";
  64. }
  65. .icon-addRound:before {
  66. content: "\e608";
  67. }
  68. .icon-wechat:before {
  69. content: "\e609";
  70. }
  71. .icon-friend:before {
  72. content: "\e60b";
  73. }
  74. .icon-share:before {
  75. content: "\e610";
  76. }
  77. .icon-thumbs:before {
  78. content: "\e611";
  79. }
  80. .icon-arrow:before {
  81. content: "\e613";
  82. }
  83. .icon-message:before {
  84. content: "\e612";
  85. }
  86. </style>