【问题标题】:Importing tex2max.js into an angular project via npm / index.html通过 npm / index.html 将 tex2max.js 导入 Angular 项目
【发布时间】:2020-10-30 23:33:09
【问题描述】:

当我尝试使用declare var tex2max: any; 导入tex2max 时,我得到一个ReferenceError: tex2max is not defined。但这不会发生在其他 npm 包中。我尝试通过安装 npm 包和 index.html 中的脚本标签来绑定脚本,但无济于事。

这里是源代码的CDN文件:

https://unpkg.com/tex2max@1.3.0/lib/tex2max.js

【问题讨论】:

  • 为什么不在你正在使用的文件中import TeX2Max from 'tex2max'

标签: javascript angular npm import


【解决方案1】:

如果项目作者更正了他们的包,你可以这样做:

import TeX2Max from 'tex2max';

但这以错误结束 [编辑:on stackblitz]

Error in /turbo_modules/tex2max@1.3.0/lib/tex2max.js (13:28806)
Cannot assign to read only property 'exports' of object '[object Object]'

最好的选择是向作者提出问题。

Stackblitz example

【讨论】:

  • 不知道为什么我之前没有尝试过(我想我试过了,但又出现了一个错误),但它成功了!
猜你喜欢
  • 1970-01-01
  • 2022-01-04
  • 1970-01-01
  • 1970-01-01
  • 2017-11-30
  • 1970-01-01
  • 2023-03-22
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多