s-richtext-block.vue 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <!-- 装修营销组件:营销文章 -->
  2. <template>
  3. <view
  4. class="richtext"
  5. :style="[
  6. {
  7. marginLeft: styles.marginLeft + 'px',
  8. marginRight: styles.marginRight + 'px',
  9. marginBottom: styles.marginBottom + 'px',
  10. marginTop: styles.marginTop + 'px',
  11. padding: styles.padding + 'px',
  12. },
  13. ]"
  14. >
  15. <mp-html :content="state.content"></mp-html>
  16. </view>
  17. </template>
  18. <script setup>
  19. import { reactive, onMounted } from 'vue';
  20. import ArticleApi from '@/sheep/api/promotion/article';
  21. const props = defineProps({
  22. data: {
  23. type: Object,
  24. default: {},
  25. },
  26. styles: {
  27. type: Object,
  28. default() {},
  29. },
  30. });
  31. const state = reactive({
  32. content: '',
  33. });
  34. onMounted(async () => {
  35. const { data } = await ArticleApi.getArticle(props.data.id);
  36. state.content = data.content;
  37. });
  38. </script>
  39. <style lang="scss" scoped>
  40. // 修复 https://t.zsxq.com/8v0JG 反馈的问题,richtext height 不自适应的问题
  41. .richtext {
  42. width: 100%;
  43. height: auto;
  44. }
  45. </style>