angular – 在Ionic 2中使用NodeJS.Timer时找不到命名空间NodeJS
发布时间:2020-12-17 10:33:55 所属栏目:安全 来源:网络整理
导读:我试图将我在 https://github.com/bevacqua/dragula/issues/289#issuecomment-277143172上找到的一些代码用于我的Ionic项目. 当我运行代码时,我得到一个错误找不到命名空间’NodeJS’,错误引用touchTimeout:NodeJS.Timer; 如何调整下面的代码以使NodeJS.Tim
我试图将我在
https://github.com/bevacqua/dragula/issues/289#issuecomment-277143172上找到的一些代码用于我的Ionic项目.
当我运行代码时,我得到一个错误找不到命名空间’NodeJS’,错误引用touchTimeout:NodeJS.Timer; 如何调整下面的代码以使NodeJS.Timer行工作? import { Directive,ElementRef,HostListener } from '@angular/core'; @Directive({ selector: '[delayDragLift]' }) export class DelayDragLiftDirective { dragDelay: number = 200; // milliseconds draggable: boolean = false; touchTimeout: NodeJS.Timer; @HostListener('touchmove',['$event']) // @HostListener('mousemove',['$event']) onMove(e: Event) { if (!this.draggable) { e.stopPropagation(); clearTimeout(this.touchTimeout); } } @HostListener('touchstart',['$event']) // @HostListener('mousedown',['$event']) onDown(e: Event) { this.touchTimeout = setTimeout(() => { this.draggable = true; },this.dragDelay); } @HostListener('touchend',['$event']) // @HostListener('mouseup',['$event']) onUp(e: Event) { clearTimeout(this.touchTimeout); this.draggable = false; } constructor(private el: ElementRef) { } }
打开src / tsconfig.app.json *.
将“node”添加到“types”数组中. 例: { "extends": "../tsconfig.json","compilerOptions": { "outDir": "../out-tsc/app","baseUrl": "./","module": "es2015","types": [ "node" ] },"exclude": [ "test.ts","**/*.spec.ts" ] } *如果此文件不存在,请将指定的部分添加到根文件夹中的tsconfig.json. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |