最新消息: 电脑我帮您提供丰富的电脑知识,编程学习,软件下载,win7系统下载。

在打字稿进口NPM包

IT培训 admin 10浏览 0评论

在打字稿进口NPM包

我想在我的joystick.ts导入gpiobutton包,但我没有找到的方式。

我试图与通常的:var GPIO =需要“gpiobutton”,也有:从“gpiobutton”,但没有进口gpiobutton工作。

我已经看到了,我可以用“确定”,但它-S不工作。

我最后的尝试是:VAR GPIO:任何=需要(“GPIO”),但我有“模块gpiobutton尚未上下文尚未加载:_ http://requirejs ......”

我怎样才能成功导入此包?

import { LogManager, inject } from 'aurelia-framework';

// const remote:Electron.Remote =   (<any>window).nodeRequire("electron").remote;
//const remote:Electron.Remote = (<any>window).nodeRequire("electron").remote;

// var gpio = require("odroid-gpio");
let logger = LogManager.getLogger('Joystick');
import { Config } from '../config';

var gpio: any = require('gpiobutton')

export class Joystick {
  constructor(config: Config) {
    if (!config.get('helmet.joystick.hasjoystick')) {
        return;
    }
    else {
        var buttonSpec = { gpiono: 134 };
        var button134 = new gpio.button(buttonSpec);
        button134.activate();
        console.log(button134);
    }
  }

}   
回答如下:
import * as Gpio from 'gpiobutton';

在打字稿进口NPM包

我想在我的joystick.ts导入gpiobutton包,但我没有找到的方式。

我试图与通常的:var GPIO =需要“gpiobutton”,也有:从“gpiobutton”,但没有进口gpiobutton工作。

我已经看到了,我可以用“确定”,但它-S不工作。

我最后的尝试是:VAR GPIO:任何=需要(“GPIO”),但我有“模块gpiobutton尚未上下文尚未加载:_ http://requirejs ......”

我怎样才能成功导入此包?

import { LogManager, inject } from 'aurelia-framework';

// const remote:Electron.Remote =   (<any>window).nodeRequire("electron").remote;
//const remote:Electron.Remote = (<any>window).nodeRequire("electron").remote;

// var gpio = require("odroid-gpio");
let logger = LogManager.getLogger('Joystick');
import { Config } from '../config';

var gpio: any = require('gpiobutton')

export class Joystick {
  constructor(config: Config) {
    if (!config.get('helmet.joystick.hasjoystick')) {
        return;
    }
    else {
        var buttonSpec = { gpiono: 134 };
        var button134 = new gpio.button(buttonSpec);
        button134.activate();
        console.log(button134);
    }
  }

}   
回答如下:
import * as Gpio from 'gpiobutton';

与本文相关的文章

发布评论

评论列表 (0)

  1. 暂无评论