gpt4 book ai didi

javascript - 将 JavaScript 导入到 Angular2

转载 作者:行者123 更新时间:2023-12-03 03:32:51 25 4
gpt4 key购买 nike

我有 angular2 应用程序,我想在其中使用外部 JS 文件中的 hlghttamyJSfile.js

var hlghtta = function (b, t, re, c) {
"use strict";
.......some functions here
};
module.exports = hlghtta;

但是我无法将其导入到我的组件中

import hlghtta from "hlghtta";

我已经将 myJSfile.js 添加到 .angular-cli.json你能帮忙吗?可能很简单。

最佳答案

试试这个

理想情况下,您应该进行打字,但如果没有,您可以使用这种方式。您还可以查看这个link了解更多信息

declare var hlghtta: any;

import '../../../../hlghtta.js';
export class Component {
ngOnInit() {
new hlghtta(params);
}
}

关于javascript - 将 JavaScript 导入到 Angular2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46008350/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com