font-amount.vue 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <template>
  2. <div :style="{ fontSize: amount_font_size + 'px' }">
  3. <a-tooltip :title="amount" >
  4. <span class="content" :style="{ fontSize: amount_font_size + 'px' }">{{ getBit(amount) }}</span>
  5. </a-tooltip>
  6. </div>
  7. </template>
  8. <script setup>
  9. import { ref, defineProps, onMounted, watch } from 'vue'
  10. import { getBit } from "@/uilts/help";
  11. let props = defineProps({
  12. amount: {
  13. type: String,
  14. default: ''
  15. },
  16. width: {
  17. type: Number,
  18. default: 360
  19. },
  20. fontSize: {
  21. type: Number,
  22. default: 56
  23. },
  24. })
  25. let amount_font_size = ref(60);
  26. watch(props, () => {
  27. setFontSize()
  28. })
  29. function setFontSize(){
  30. let amount = getBit(props.amount);
  31. let _num = parseInt(props.width / amount.length);
  32. amount_font_size.value = _num < props.fontSize ? _num : props.fontSize;
  33. }
  34. onMounted(() => {
  35. setFontSize()
  36. })
  37. </script>
  38. <style lang="scss" scoped>
  39. .content {
  40. word-break: break-all;
  41. margin-left: 12px;
  42. font-weight: 800;
  43. font-size: 60px;
  44. line-height: 76px;
  45. color: #FFFFFF;
  46. }
  47. </style>