message-text.vue 962 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <template>
  2. <template v-for="(item, index) in data.text" :key="index">
  3. <span class="text-box" v-if="item.name === 'text'">{{ item.text }}</span>
  4. <img class="text-img" v-else-if="item.name === 'img'" :src="item.src" />
  5. </template>
  6. </template>
  7. <script lang="ts">
  8. import { defineComponent, watchEffect, reactive, toRefs } from 'vue';
  9. export default defineComponent({
  10. props: {
  11. data: {
  12. type: Object,
  13. default: () => ({})
  14. }
  15. },
  16. setup(props: any, ctx: any) {
  17. const data = reactive({
  18. data: {}
  19. });
  20. watchEffect(() => {
  21. data.data = props.data;
  22. });
  23. return {
  24. ...toRefs(data)
  25. };
  26. }
  27. });
  28. </script>
  29. <style lang="scss" scoped>
  30. @import url('../../../styles/common.scss');
  31. @import url('../../../styles/icon.scss');
  32. .text-img {
  33. width: 20Px;
  34. height: 20Px;
  35. }
  36. .text-box {
  37. white-space: pre-wrap;
  38. font-size: inherit;
  39. word-break: break-word;
  40. font-size: 14Px;
  41. text-size-adjust: none;
  42. }
  43. </style>