Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 解决 toolbar 放置 popover 组件中不显示 #14

Closed
wants to merge 1 commit into from

Conversation

th-wu
Copy link

@th-wu th-wu commented Mar 24, 2023

toolbar 放置popover组件中,创建时机不对

<template>
  <Popover placement="topLeft" trigger="click">
    <template slot="content">
      <Toolbar :mode="mode" :editor="editor" />
    </template>
    <Editor
      :defaultConfig="editorConfig"
      :value="value"
      @onChange="onEditorChange"
      @onCreated="onCreated"
    />
  </Popover>
</template>

<script>
import { Popover } from 'ant-design-vue';
import { Editor, Toolbar } from '@wangeditor/editor-for-vue';

export default {
  components: { Popover, Editor, Toolbar },
  props: {
    value: {
      type: String,
      default: '',
    },
    onChange: {
      type: Function,
    },
  },
  data() {
    return {
      editor: null,
      mode: 'simple',
      editorConfig: {
        placeholder: '请输入内容...',
      },
    };
  },
  methods: {
    onCreated(editor) {
      this.editor = Object.seal(editor);
    },
    onEditorChange(editor) {
      this.onChange(editor.getHtml());
    },
  },
  beforeDestroy() {
    const editor = this.editor;
    if (editor == null) return;
    editor.destroy();
  },
};
</script>

th-wu

This comment was marked as off-topic.

@th-wu th-wu closed this by deleting the head repository Jun 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant