richTextEditor.vue 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <template>
  2. <!-- 富文本 -->
  3. <view v-if="description" :style="[boxStyle]">
  4. <view class="rich_text">
  5. <!-- #ifdef MP || APP-PLUS -->
  6. <mp-html :content="description" :tag-style="tagStyle" selectable="true" show-img-menu="true"/>
  7. <!-- #endif -->
  8. <!-- #ifdef H5 -->
  9. <view v-html="description"></view>
  10. <!-- #endif -->
  11. </view>
  12. </view>
  13. </template>
  14. <script>
  15. // +----------------------------------------------------------------------
  16. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  17. // +----------------------------------------------------------------------
  18. // | Copyright (c) 2016~2025 https://www.crmeb.com All rights reserved.
  19. // +----------------------------------------------------------------------
  20. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  21. // +----------------------------------------------------------------------
  22. // | Author: CRMEB Team <admin@crmeb.com>
  23. // +----------------------------------------------------------------------
  24. import mpHtml from "@/uni_modules/mp-html/components/mp-html/mp-html.vue";
  25. export default {
  26. name: 'richText',
  27. props: {
  28. dataConfig: {
  29. type: Object,
  30. default: () => {}
  31. },
  32. },
  33. data(){
  34. return{
  35. tagStyle: {
  36. img: 'width:100%;display:block;',
  37. table: 'width:100%',
  38. video: 'width:100%'
  39. },
  40. }
  41. },
  42. components:{
  43. mpHtml
  44. },
  45. computed: {
  46. //最外层盒子的样式
  47. boxStyle() {
  48. return {
  49. borderRadius: this.dataConfig.bgStyle.val * 2 + 'rpx',
  50. background: `linear-gradient(${this.dataConfig.bgColor.color[0].item}, ${this.dataConfig.bgColor.color[1].item})`,
  51. margin: this.dataConfig.mbConfig.val * 2 + 'rpx' + ' ' + this.dataConfig.lrConfig.val * 2 + 'rpx' +
  52. ' ' + 0,
  53. }
  54. },
  55. //富文本内容
  56. description() {
  57. return this.dataConfig.richText.val.replace(/\<img/gi, '<img style="max-width:100%;height:auto" ')
  58. .replace(/style="text-wrap: wrap;"/gi, '')
  59. }
  60. },
  61. methods: {
  62. }
  63. }
  64. </script>
  65. <style lang="scss" scoped>
  66. .rich_text {
  67. padding: 10px;
  68. width: 100%;
  69. overflow: hidden;
  70. }
  71. </style>