quilleditor.vue 918 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. <!-- 组件代码如下 -->
  2. <template>
  3. <div>
  4. <script id="editor" type="text/plain"></script>
  5. </div>
  6. </template>
  7. <script>
  8. export default {
  9. name: 'quilleditor',
  10. data () {
  11. return {
  12. editor: null
  13. }
  14. },
  15. props: {
  16. defaultMsg: {
  17. type: String
  18. },
  19. config: {
  20. type: Object
  21. }
  22. },
  23. mounted() {
  24. const _this = this;
  25. this.editor = UE.getEditor('editor', this.config); // 初始化UE
  26. this.editor.addListener("ready", function () {
  27. _this.editor.setContent(_this.defaultMsg); // 确保UE加载完成后,放入内容。
  28. });
  29. },
  30. methods: {
  31. getUEContent() { // 获取内容方法
  32. return this.editor.getContent()
  33. }
  34. },
  35. destroyed() {
  36. this.editor.destroy();
  37. }
  38. }
  39. </script