wangeditor 使用 base64 保存图片失败

发布于 2022-09-07 22:23:55 字数 1194 浏览 14 评论 0

请问有遇到过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>

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

不奢求什么 2022-09-14 22:23:55

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文