cytoscape.js和Angular6 [英] cytoscape.js and Angular6

查看:156
本文介绍了cytoscape.js和Angular6的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的有角项目中导入 cytoscape.js 库,但是我不知道如何去做吧.据我所知,目前尚无用于Angular的官方cytoscape模块,有什么方法可以手动导入cytoscape吗?

I want to import cytoscape.js library in my angular project, but I don't know how to do it. As far as I know, there is no official cytoscape module for angular, is there any way to import cytoscape manually?

推荐答案

更新:请参阅DC Joo的答案,这应该是公认的答案.

UPDATE: Please see the answer of D.C. Joo, this should be the accepted answer.

实际上,在Angular中导入JS库没问题,这就是我如何使用npm和Angular6做到这一点:

Actually, it's no problem to import JS libraries in Angular, thats how I do it using npm and Angular6:

  1. 运行npm install cytoscape
  2. https://github.com/cytoscape/cytoscape.js/blob/master/dist/cytoscape.min.js
  3. 下载Cytoscape
  4. 在Angular根目录中创建目录scripts并将下载的文件放在此处
  5. 将下载的脚本包含在angular.json中:

  1. Run npm install cytoscape
  2. Download Cytoscape from https://github.com/cytoscape/cytoscape.js/blob/master/dist/cytoscape.min.js
  3. Create a directory scripts in your Angular root directory and place the downloaded file there
  4. Include your downloaded script in your angular.json:

项目":{ 我的项目": { ... 建筑师":{ 建造": { ... 脚本":[ "src/scripts/cytoscape.min.js" ] ... (注意:很抱歉,我尝试过格式化,但是它不起作用)

"projects": { "myproject": { ... "architect": { "build": { ... "scripts": [ "src/scripts/cytoscape.min.js" ] ... (NOTE: Sorry about the formatting, I tried but it does not want to work)

在要使用Cytoscape的Angular组件中,将declare var cytoscape: any;添加到导入中

In the Angular component where you want to use Cytoscape, add declare var cytoscape: any; to the imports

现在,您可以像平常一样使用Cytoscape,玩得开心:)

Now you can use Cytoscape like you would normally, have fun :)

这篇关于cytoscape.js和Angular6的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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