lv-icon.vue 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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('../public/font/iconfont.woff2?t=1629537928872') format('woff2'),
  52. url('../public/font/iconfont.woff?t=1629537928872') format('woff'),
  53. url('../public/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. </style>