You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Angular中使用quill-rich-voice-editor报错:moduleClass is not a constructor

解决Quill中rich-voice-editor模块构造函数错误问题

问题原因

出现TypeError: moduleClass is not a constructor错误,是因为未正确将rich-voice-editor模块注册到Quill中,直接在配置里设为true无法让Quill识别对应的模块类。

解决步骤

  • 导入模块
    在组件文件顶部添加模块导入语句:

    import Quill from 'quill';
    import RichVoiceEditor from 'quill-rich-voice-editor';
    
  • 注册模块到Quill
    在实例化Quill之前,先完成模块注册:

    Quill.register('modules/rich-voice-editor', RichVoiceEditor);
    
  • 保留原有配置
    保持Quill实例配置中'rich-voice-editor': true的设置,此时Quill已能识别到注册好的模块类:

    const quill = new Quill(this.richTextEditor.nativeElement, {
      theme: 'snow',
      modules: {
        toolbar: ssmlToolbarOptions,
        'rich-voice-editor': true
      },
      placeholder: '<speak>Your text here</speak>',
    });
    

额外检查点

  • 确认quill@^1.3.6和quill-rich-voice-editor@^0.4.0版本兼容性,当前版本组合无适配问题
  • 检查Angular打包配置,确保模块未被tree-shaking机制误删

内容的提问来源于stack exchange,提问作者M Mohsin Mahar

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.12 02:57:34