首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >TypeError:无法读取未定义(react-quill)的属性“imports”

TypeError:无法读取未定义(react-quill)的属性“imports”
EN

Stack Overflow用户
提问于 2021-05-29 01:38:06
回答 1查看 487关注 0票数 2

错误:

代码语言:javascript
复制
TypeError: Cannot read property 'imports' of undefined
(anonymous function)
C:/Users/abc/finaltest/node_modules/quill-image-resize-module/image-resize.min.js:1

我使用以下命令安装了quill-image-resize:

代码语言:javascript
复制
npm i --save quill-image-resize-module

由于我使用的是react,因此没有tsconfig文件,所以我无法遵循互联网上可用的解决方案。

我的代码:

代码语言:javascript
复制
import ReactQuill from 'react-quill'
import Quill from 'quill';
import { ImageResize } from 'quill-image-resize-module'; 
Quill.register('modules/imageResize', ImageResize);

modules = {
        
        toolbar: {
            container:this.toolbarOptions,
            
        },
        ImageResize: {
            modules: [ 'Resize', 'DisplaySize', 'Toolbar' ]
        }        
        
}

这是我将鼠标悬停在import语句上时得到的结果

代码语言:javascript
复制
Could not find a declaration file for module 'quill-image-resize-module'. 'c:/Users/abc/final blog/finaltest/node_modules/quill-image-resize-module/image-resize.min.js' implicitly has an 'any' type.

我尝试使用require语句,但错误仍然存在。

以下是我的依赖项:

代码语言:javascript
复制
"quill-image-resize-module": "^3.0.0",
"quill-image-resize-module-react": "^3.0.0",
"react": "^17.0.2",
"react-quill": "^1.3.5",

我用quill-image-resize-module-react尝试了同样的方法,但是我不能解决这个错误。我的reactquill编辑器在此之前工作过。我没有使用webpack,所以我甚至没有使用webpack.config.js来尝试解决这个问题。我还没有对node_modules/quill-image-resize-module中的原始文件进行任何更改。

这是我第一次尝试react,因此希望能得到一些帮助。我非常确定这是我眼皮底下看不见的东西。谢谢您抽时间见我。

EN

回答 1

Stack Overflow用户

发布于 2021-10-12 18:16:58

尝试在此处安装已修复的版本:https://www.npmjs.com/package/quill-image-resize-module--fix-imports-error

它会解决这个问题。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67743358

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档