index.vue 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <template>
  2. <div class="Editor">
  3. <vue-ueditor-wrap :config="config" v-model="html" />
  4. <Button class="Editor__preview" type="info" @click="preview">预览</Button>
  5. </div>
  6. </template>
  7. <script>
  8. import VueUeditorWrap from './ueditor'
  9. export default {
  10. props: ['content'],
  11. components: {
  12. VueUeditorWrap,
  13. },
  14. data () {
  15. return {
  16. html: '',
  17. config: {
  18. serverUrl: `${process.env.API_URL.default}config/ueupload`,
  19. toolbars: [[
  20. 'fontsize',
  21. 'paragraph',
  22. 'lineheight',
  23. 'forecolor',
  24. 'backcolor',
  25. 'bold',
  26. 'italic',
  27. 'underline',
  28. 'strikethrough',
  29. 'justifyleft',
  30. 'justifyright',
  31. 'justifycenter',
  32. 'blockquote',
  33. 'insertimage',
  34. 'removeformat',
  35. 'formatmatch',
  36. 'source',
  37. ]],
  38. imageBlockLine: 'center',
  39. autoHeightEnabled: false,
  40. initialFrameWidth: 'auto',
  41. initialFrameHeight: 400,
  42. },
  43. }
  44. },
  45. watch: {
  46. content: {
  47. type: String,
  48. default: '',
  49. immediate: true,
  50. handler (v) {
  51. this.html = v
  52. },
  53. },
  54. html (html) {
  55. this.$emit('on-change', html)
  56. },
  57. },
  58. methods: {
  59. preview () {
  60. this.$Modal.info({
  61. title: '预览',
  62. scrollable: true,
  63. render: h => {
  64. return h('div', {
  65. style: {
  66. width: '375px',
  67. height: '500px',
  68. overflow: 'scroll',
  69. },
  70. domProps: {
  71. innerHTML: this.html,
  72. },
  73. })
  74. },
  75. })
  76. },
  77. },
  78. }
  79. </script>
  80. <style lang="scss" scoped>
  81. .Editor__preview {
  82. margin-top: 10px;
  83. }
  84. </style>