s-richtext-block.vue 855 B

1234567891011121314151617181920212223242526272829303132333435363738
  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 sheep from '@/sheep';
  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 { error, data } = await sheep.$api.data.richtext(props.data.id);
  34. if (error === 0) {
  35. state.content = data.content;
  36. }
  37. });
  38. </script>