fs-icon.vue 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <template>
  2. <view
  3. :class="[type, colorType, source === 'inner' ? 'fsfont' : 'iconfont']"
  4. :style="style"
  5. @click="handleClick"
  6. >
  7. </view>
  8. </template>
  9. <script setup>
  10. import { computed } from 'vue'
  11. const props = defineProps({
  12. type: String,
  13. size: {
  14. type: String,
  15. default: '36rpx',
  16. },
  17. color: String,
  18. colorType: {
  19. type: String,
  20. validator(value) {
  21. return ['primary', 'success', 'info', 'warning', 'danger', 'gray'].includes(value)
  22. }
  23. },
  24. source: {
  25. type: String,
  26. default: 'inner'
  27. },
  28. link: String,
  29. linkType: {
  30. type: String,
  31. default: 'navigateTo'
  32. },
  33. rotate: String
  34. })
  35. const emits = defineEmits(['click'])
  36. const style = computed(() => {
  37. let style = `font-size: ${props.size};`
  38. if (props.color) {
  39. style += `color: ${props.color};`
  40. }
  41. if (props.rotate) {
  42. style += `transform: rotate(${props.rotate}deg);`
  43. }
  44. return style
  45. })
  46. const handleClick = () => {
  47. if (props.link) {
  48. uni[props.linkType]({
  49. url: props.link
  50. })
  51. }
  52. emits('click')
  53. }
  54. </script>
  55. <style lang="scss" scoped>
  56. @import '../../common/iconfont.css';
  57. @import './icon.css';
  58. .fsfont{
  59. display: inline-block;
  60. vertical-align: middle;
  61. line-height: 1;
  62. }
  63. </style>