wangeditor 使用 base64 保存图片失败

请问有遇到过wangeditor 使用base64保存图片时 上传不上图片的问题吗。

clipboard.png
代码如下

<template>
    <div class="editor-wrap">
        <div class="account-editor" ref="editor"></div>
    </div>
</template>
<script>
import WangEditor from 'wangeditor';
export default {
    name:'editor',
    data(){
        return{
            editor: '',  // 存放实例化的wangEditor对象,在多个方法中使用
        }
    },
    props:['catchData'],
    methods: {
        createEditor(){  // 创建编辑器
            this.editor = new WangEditor(this.$refs.editor);
            this.initEditorConfig();  // 初始化编辑器配置,在create之前
            this.editor.customConfig.onchange = (html) => {
                this.editorContent = html;
                this.catchData(html)  //把这个html通过catchData的方法传入父组件
            }
            this.editor.create();  // 生成编辑器
        },
        initEditorConfig(){  // 初始化编辑器配置
            this.editor.customConfig.uploadImgShowBase64 = true;   // 使用 base64 保存图片
        },
    },
    mounted(){
        this.createEditor()
    }
}
</script>

上传时不显示图片也不报错,有遇到过的吗?

阅读 5.1k
1 个回答

需要聚焦 div如果上来就点击上传图片的话是不行的 需要先点击一下div的框 然后才可以

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题