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

上传图片的时候选择自定义上传customUpload,图片是上传成功并返回路径了,但insertFn报错了 #6008

Open
didikanbudong opened this issue Dec 5, 2024 · 1 comment

Comments

@didikanbudong
Copy link

问题描述

上传图片的时候选择自定义上传customUpload,图片是上传成功并返回路径了,但insertFn报错了,报错内容:
Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'replace')
at a$ (index.esm.js:15:26215)
at index.esm.js:15:40046
at index.esm.js:15:1785
at Object.next (index.esm.js:15:1886)
at a2 (index.esm.js:15:628)

wangEditor 版本

"@wangeditor/editor": "^5.1.23",
"@wangeditor/editor-for-vue": "^5.1.12",

是否查阅了文档 ?

最小成本的复现步骤

(请告诉我们,如何最快的复现该问题?)

  • 步骤一
  • 步骤二
  • 步骤三
@dai-shifu
Copy link

提供一下关键代码。
比如 uploadImage 配置 , res 返参的格式。

type InsertFnType = (url: string, alt: string, href: string) => void;
/**
 * 编辑器图片上传配置
 */
export const uploadImage = {
  server: baseURL + '/api/attachment/upload',
  fieldName: 'file',
  customInsert(res: any, insertFn: InsertFnType) {
    // 从 res 中找到 url alt href ,然后插入图片
    const { attachmentUrl: url, attachmentName: alt } = res.data || {};

    // console.log('imageRes',res)
    insertFn(url, alt, '');
  },
};

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

No branches or pull requests

2 participants