s-richtext-block.vue 841 B

123456789101112131415161718192021222324252627282930313233343536
  1. <template>
  2. <view
  3. :style="[
  4. {
  5. marginLeft: styles.marginLeft + 'px',
  6. marginRight: styles.marginRight + 'px',
  7. marginBottom: styles.marginBottom + 'px',
  8. marginTop: styles.marginTop + 'px',
  9. padding: styles.padding + 'px',
  10. },
  11. ]"
  12. >
  13. <mp-html class="richtext" :content="state.content"></mp-html>
  14. </view>
  15. </template>
  16. <script setup>
  17. import { reactive, onMounted } from 'vue';
  18. import ArticleApi from '@/sheep/api/promotion/article';
  19. const props = defineProps({
  20. data: {
  21. type: Object,
  22. default: {},
  23. },
  24. styles: {
  25. type: Object,
  26. default() {},
  27. },
  28. });
  29. const state = reactive({
  30. content: '',
  31. });
  32. onMounted(async () => {
  33. const { data } = await ArticleApi.getArticle(props.data.id);
  34. state.content = data.content;
  35. });
  36. </script>