我正在尝试向我的网关添加Simpl5 JavaScript库失败。 我把SIPml-api.js和SIPml.js在webapp/content/scripts文件夹中。如何在网关项目中添加外部JavaScript库
在.angular-cli.json我已经更新脚本数组是这样的:
"scripts": [
"content/scripts/SIPml-api.js",
"content/scripts/SIPml.js"
]
然后我尝试调用SIPml在组件这样的:
import { Component, OnInit } from '@angular/core';
declare var SIPml: any;
。
ngOnInit() {
SIPml.setDebugLevel((window.localStorage && window.localStorage.getItem('org.doubango.expert.disable_debug') === 'true') ? 'error' : 'info');
}
我得到错误的ReferenceError:SIPml未在控制台中定义。
有人可以帮忙吗?
我认为你的函数应该叫做'AfterViewInit' –
。JHipster webpack的配置不使用.angular-cli.json。您是否尝试将SIPml * .js复制到webapp/app文件夹,然后按照https://stackoverflow.com/questions/38318542/how-to-use-javascript-in-typescript –
我试图复制SIPml * .js到webapp /应用程序,但我仍然没有定义SIPml。我还添加了“allowJs”:对tsconfig.json是true。 – freemanpolys