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

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

问题描述

我正在尝试将 Simpl5 JavaScript库添加到我的网关不成功. 我已将 SIPml-api.js SIPml.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 .

有人可以帮忙吗?

推荐答案

JHipster不完全支持角度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天全站免登陆