Tag: 打字稿

如何将JQuery导入到Typescript文件中?

更新 无需导入。 相反,我需要添加对文件顶部的引用。 所以我的WebAPI.js的第一行应该是/// 而不是import { $ } from ‘../jquery-3.1.1’;的import { $ } from ‘../jquery-3.1.1’; 我试图导入jQuery以在Typescript文件中使用,但我收到的各种错误与我尝试的一切。 我按照这里和这里的解决方案,但没有任何运气。 tsconfig.json { “compilerOptions”: { “removeComments”: true, “preserveConstEnums”: true, “out”: “Scripts/CCSEQ.Library.js”, “module”: “amd”, “sourceMap”: true, “target”: “es5”, “allowJs”: true } WebAPI.js import { $ } from ‘../jquery-3.1.1’; export class ExpenseTransaction extends APIBase { constructor() { super(); } Get(): void […]

如何在角度2中使用jQuery和javascript

import {Component, ElementRef, OnInit} from ‘angular2/core’; declare var jQuery:any; @Component({ selector: ‘jquery-integration’, templateUrl: ‘./components/jquery-integration/jquery-integration.html’ }) export class JqueryIntegration implements OnInit { elementRef: ElementRef; constructor(elementRef: ElementRef) { this.elementRef = elementRef; } ngOnInit() { jQuery(this.elementRef.nativeElement).draggable({ containment:’#draggable-parent’ }); } } jQuery可以像Angular2一样在Typeular中使用吗? 如何在Angular2中使用jQuery和JavaScript?