【发布时间】:2019-01-31 04:38:54
【问题描述】:
我有一个简单的问题,我想在 Angular 6 中使用 lame js 库,但我无法实现。
stackbltiz 演示:
https://stackblitz.com/edit/angular-whygjq?file=angular.json
库蹩脚的 js:
https://github.com/zhuker/lamejs
我完成的步骤:
- npm install lamejs
- 在脚本中的 angular.json 中,我已将路径粘贴到 node_modules:
“node_modules/lamejs/lame.min.js”
- 我一直坚持如何在应用程序组件中使用它,在这里的其他主题中,我发现诸如:import * as lame from '????'
如何正确使用它
【问题讨论】:
-
您是否在组件中尝试过
const lamejs = require("lamejs");?而不是import * as lame.. -
我不确定,但 require 来自 nodejs 应用程序,它不起作用
-
你也可以用这个。与 nodejs 应用程序相同。当你使用这个时,你不需要将
node_module....js 导入到angular.json。 -
这是向您展示如何使用
require(yourmodule)的 stackblitz :stackblitz.com/edit/angular-jhun6j
标签: angular