richtext.vue 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <template>
  2. <s-layout class="set-wrap" :title="state.title" :bgStyle="{ color: '#FFF' }">
  3. <view class="ss-p-30"><mp-html class="richtext" :content="state.content"></mp-html></view>
  4. </s-layout>
  5. </template>
  6. <script setup>
  7. import { onLoad } from '@dcloudio/uni-app';
  8. import { reactive } from 'vue';
  9. import sheep from '@/sheep';
  10. const state = reactive({
  11. title: '',
  12. content: '',
  13. });
  14. async function getRichTextContent(id) {
  15. const { error, data } = await sheep.$api.data.richtext(id);
  16. if (error === 0) {
  17. state.content = data.content;
  18. if (state.title === '') {
  19. state.title = data.title;
  20. uni.setNavigationBarTitle({
  21. title: state.title,
  22. });
  23. }
  24. }
  25. }
  26. onLoad((options) => {
  27. if (options.title) {
  28. state.title = options.title;
  29. uni.setNavigationBarTitle({
  30. title: state.title,
  31. });
  32. }
  33. getRichTextContent(options.id);
  34. });
  35. </script>
  36. <style lang="scss" scoped>
  37. .set-title {
  38. margin: 0 30rpx;
  39. }
  40. .richtext {
  41. }
  42. </style>