我正在嘗試向我的網關添加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