【问题标题】:TypeError: Cannot read property 'imports' of undefined (react-quill)TypeError:无法读取未定义的属性“导入”(react-quill)
【发布时间】:2021-08-16 23:12:14
【问题描述】:

错误:

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 使用:

npm i --save quill-image-resize-module

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

我的代码:

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' ]
        }        
        
}

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

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 语句,但错误仍然存​​在。

这些是我的依赖项:

"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 中的原始文件进行任何更改。

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

【问题讨论】:

  • 同样的问题,我使用 vue 但没有 webpack 文件,所以无法遵循互联网解决方案。尽管有些人建议将图像调整大小从 ^3 降级为 ^1。
  • 谢谢你。我会尝试看看它是否更好。 @AadeshDhakal

标签: javascript reactjs typeerror react-quill


【解决方案1】:

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

它会解决问题。

【讨论】:

    猜你喜欢
    • 2023-04-01
    • 1970-01-01
    • 2021-09-24
    • 2020-07-10
    • 2019-07-07
    • 2021-03-10
    • 2020-02-10
    • 2021-04-17
    • 1970-01-01
    相关资源
    最近更新 更多