我有一个 Angular 应用程序,我试图在其中导入一个具有构造函数的 JS 文件。但是当我运行该应用程序时,webpack 会抛出错误。
资产中的Javascript文件:
TestServiceClient = function(arg1, arg2) {
};
module.exports = TestServiceClient;
module.exports.default = TestServiceClient;
在 Angular 中导入:
var TestServiceClient = require('../assets/test');
@Injectable()
export class ServiceTest {
constructor() {
const svc = new TestServiceClient('testarg1', 'testarg2');
}
}
这是我得到的错误:
Uncaught ReferenceError: TestServiceClient is not defined
at 3472 (test.js:1:18)
at __webpack_require__ (bootstrap:19:1)
您能帮我找出问题所在吗?
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
我必须以这种方式导出它:
exports.TestServiceClient = function(arg1, arg2) { };