ElemText.vue 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <template>
  2. <div class="elem-text" :style="elemStyles">
  3. <div class="text-body" :style="styles">
  4. <span
  5. v-for="(cont, index) in data.content"
  6. :key="index"
  7. :class="`cont-${cont.type}`"
  8. >{{ cont.content }}</span
  9. >
  10. </div>
  11. </div>
  12. </template>
  13. <script>
  14. export default {
  15. name: "ElemText",
  16. props: {
  17. data: {
  18. type: Object,
  19. default() {
  20. return {};
  21. },
  22. },
  23. },
  24. data() {
  25. return {};
  26. },
  27. computed: {
  28. styles() {
  29. return {
  30. fontWeight: this.data.fontWeight,
  31. fontFamily: this.data.fontFamily,
  32. fontSize: this.data.fontSize,
  33. color: this.data.color,
  34. };
  35. },
  36. elemStyles() {
  37. if (this.data.mode === "side") {
  38. return {
  39. position: "absolute",
  40. width: this.data.h + "px",
  41. height: this.data.w + "px",
  42. transform: "rotate(-90deg)",
  43. "transform-origin": "0 100%",
  44. bottom: 0,
  45. left: this.data.w + "px",
  46. };
  47. } else {
  48. return null;
  49. }
  50. },
  51. },
  52. methods: {},
  53. };
  54. </script>