简体   繁体   English

在Ionic2 TypeScript项目中使用npm JavaScript包

[英]Use npm JavaScript package in Ionic2 TypeScript project

I started my first project with Ionic2 (TypeScript) and need to use the npm JavaScript package. 我从Ionic2(TypeScript)开始了我的第一个项目,并且需要使用npm JavaScript包。 In my project I use https://github.com/huttarichard/instagram-private-api 在我的项目中,我使用https://github.com/huttarichard/instagram-private-api

I don't understand how can I properly import a class instead the require and how I should use values in constructor class. 我不明白如何正确地import类而不是require以及如何在构造函数类中使用值。

var Client = require('instagram-private-api').V1;
var device = new Client.Device('someuser');
  1. Go to /src/ 转到/ src /
  2. Open the assets folder 打开资产文件夹
  3. Create a /js/ folder inside assets 在资产内创建一个/ js /文件夹
  4. Copy your .js inside this js folder 将您的.js复制到此js文件夹中
  5. Goto /src/index.html 转到/src/index.html
  6. Add your path Go to your typescript file of choice and declare var N; 添加您的路径转到您选择的打字稿文件,并声明var N; N.yourFunction N.yourFunction

Greetings 问候

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM