如何将 Tesseract 导入 Angular2 (TypeScript)

How to import Tesseract into Angular2 (TypeScript)

我正在尝试将 Tesseract 导入 Angular2 (TypeScript)。我可以看到它保存在 node_modules 文件夹中,但是在使用

import { Tesseract } from '@types/tesseract.js';

它说:

[ts] Module '"c:/Users/black/Projects/projectCLI/tess/node_modules/@types/tesseract.js/index"' has no exported member 'Tesseract'.

在 index.d.ts 文件中有一个名为 Tesseract 的命名空间。

有没有其他方法可以导入它,还是我们看错了?

我用 npm install --save-dev @types/tesseract.js 安装了 typescript Tesseract。

如果有任何使用 tesseract 的演示教程,你能在这里link请他们吗?

提前感谢您的帮助。

您需要安装实际的 javascript 模块:
npm install tesseract.js --save

同时安装@types 声明:
npm install @types/tesseract.js --save-dev

最后执行以下导入操作:
import * as Tesseract from 'tesseract.js'

要使用图书馆检查here

@types 命令保存 this type declaration file.
这是一个命名空间,实际模块的所有内容都声明为 within.When 你做 import * as aliasname from tessreact.js,你可以使用命名空间内的所有函数作为 aliasname.functionname。示例是 the test file 相同类型的声明文件。