wangEditor上传本地图片

发布时间 2023-07-14 15:41:30作者: 幻影之舞

项目采用vue3+vite,用的wangEditor实现文章编辑的

const editorConfig = {
    MENU_CONF: {},
    placeholder: '请输入内容...' ,
}


editorConfig.MENU_CONF['uploadImage'] = {
    // 自定义上传
        async customUpload(file, insertFn) {                   // JS 语法
        // 自己实现上传,并得到图片 url alt href
            await uploadFiles(file).then( imgInfo => {
                const { filePath, name } = imgInfo
                insertFn(filePath, name, filePath)
            })
    }
}
// 上传采用minio上传的,uploadFiles为minio的上传方法,返回图片路径和名称