最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

在打字稿进口NPM包

运维笔记admin20浏览0评论

在打字稿进口NPM包

在打字稿进口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. 暂无评论