如何在网关项目中添加外部 javascript 库 [英] How to add external javascript library in a gateway project

查看:19
本文介绍了如何在网关项目中添加外部 javascript 库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将 Simpl5 javascript 库添加到我的网关不成功.我已将 SIPml-api.jsSIPml.js 放在 webapp/content/scripts 文件夹中.

I'm trying to add Simpl5 javascript library to my gateway unsuccessfully. I've put SIPml-api.js and SIPml.js in webapp/content/scripts folder.

.angular-cli.json 中,我更新了脚本数组,如下所示:

In .angular-cli.json I've update scripts array like this :

    "scripts": [
        "content/scripts/SIPml-api.js",
        "content/scripts/SIPml.js"
    ]

然后我尝试像这样在组件中调用 SIPml :

I've then try to call SIPml in component like this :

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');

}

我在控制台中收到 ERROR ReferenceError: SIPml is not defined.

有人可以帮忙吗?

推荐答案

JHipster 不完全支持 angular cli,正如@GaëlMarziou 已经在评论中提到的那样.

JHipster does not fully supports angular cli as @GaëlMarziou already mentioned in comments.

支持 CLI 的最初想法只是为了代码生成.

The original idea of supporting the CLI was only for code generation.

因此,任何 .angular-cli.json 修改都不会产生任何效果,因为 JHipster 正在使用它自己的 build/serve 链(查看 package.json 自定义脚本,它们不是基于 ng serve/build 等)检查 此问题讨论 了解更多详情.

So any .angular-cli.json modificatons won't have any effect as JHipster is using its own build/serve chain (have a look in to package.json custom scripts, they are not based on ng serve/build, etc ) check this issue discussion for more details.

你需要在 vendor.ts 中引用你的自定义 cssjs 然后当你运行 npm run serve 你会看到结果.

You need to reference your custom css and js in vendor.ts then when you run npm run serve you will see the result.

这篇关于如何在网关项目中添加外部 javascript 库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆