fangyuan
2022-12-16 9ff66017debadfc89bc0c1b796684a4d1dbe2bc3
src/components/edit/index.vue
@@ -4,25 +4,30 @@
    </div>
</template>
<script>
import E from 'wangeditor'
import wangEditor from 'wangeditor'
export default {
  props: {
    readOnly: {
      type: Boolean,
      default: () => false
    }
  },
    data() {
        return {
            editor: null
        }
    },
    props:['getMyBody'],
    mounted() {
        this.editor = new E('#edit');
        this.editor.config.height = 450;
        this.editor.config.colors = [
            '#4b9bb7',
            '#09152f'
        ]
        this.editor.config.onchange =(html)=>{
            // 第二步,监控变化,同步更新到 textarea
            this.$emit('getMyBody',html);
        this.editor = new wangEditor('#edit');
        this.editor.customConfig = this.editor.config;
        this.editor.customConfig.height = 450;
        this.editor.customConfig.colors = ['#4b9bb7', '#09152f'];
        this.editor.customConfig.placeholder = '请输入';
        this.editor.customConfig.onchangeTimeout = 500;
        this.editor.customConfig.readOnly = this.readOnly;
        this.editor.customConfig.onfocus = () => {
          this.editor.customConfig.placeholder = '';
        }
        this.editor.create();
    },