index.vue 933 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <template>
  2. <div>
  3. <div ref="editor"></div>
  4. <div :innerHTML="content.html"></div>
  5. </div>
  6. </template>
  7. <script>
  8. import { onMounted, onBeforeUnmount, ref, reactive } from "vue";
  9. import WangEditor from "wangeditor";
  10. export default {
  11. name: "reEditor",
  12. setup() {
  13. const editor = ref();
  14. const content = reactive({
  15. html: "",
  16. text: ""
  17. });
  18. let instance;
  19. onMounted(() => {
  20. instance = new WangEditor(editor.value);
  21. Object.assign(instance.config, {
  22. onchange() {
  23. content.html = instance.txt.html();
  24. }
  25. });
  26. instance.create();
  27. });
  28. onBeforeUnmount(() => {
  29. instance.destroy();
  30. instance = null;
  31. });
  32. return {
  33. editor,
  34. content
  35. };
  36. }
  37. };
  38. </script>
  39. <style lang="scss" scoped>
  40. :deep(.w-e-text-container) {
  41. z-index: 99 !important;
  42. }
  43. :deep(.w-e-toolbar) {
  44. z-index: 999 !important;
  45. position: static;
  46. }
  47. </style>