私のangluar cliプロジェクトでjQueryを使いたいです。 私はここの手順を試してみました:https://www.gurustop.net/blog/2016/11/18/3821/jquery-angular2-angularcli-how-to角度のあるcliプロジェクトにjQueryを追加できません
はjQueryの
型チェックのためのjQueryのタイプdefinationをインストールnpm install --save jquery;
をインストールします。
npm install --save-dev @types/jquery
アンギュラcli.jsonファイル内の "スクリプト" 配列にjqueryのファイルのrefeneceを追加します。
ERROR in ./src/app/app.component.ts (2,25): Module ''jquery'' resolves to a non-module entity and cannot be imported using this construct.
私がもし:私は次のエラーを取得する
ng build
を行うときに、私のapp.component.tsで"scripts": [ "../node_modules/jquery/dist/jquery.min.js" ]
インポートjqueryのは、
import { Component } from '@angular/core'; import * as jQuery from 'jquery'; @Component({ selector: 'app-root', templateUrl: './app.component.html', styleUrls: ['./app.component.scss'] }) export class AppComponent { title = 'app'; test = jQuery("body"); }
しかし
ファイルimport * as jQuery from 'jquery';
を削除し、 `ng build 'を削除します。
ERROR in ./src/app/app.component.ts (10,10): Cannot find name 'jQuery'.
ここからどこへ行くかわかりません。 @Saravanaが掲示何に基づいて
アップデート1
。 私はちょうどdeclare const $: JQueryStatic
とng build
行うと、私はエラーを取得:
ERROR in ./src/app/app.component.ts (2,19): Cannot find name 'JQueryStatic'.
を、私は彼がそれを削除する前にSaravanaは彼の最初のポストに提案何場合。
import "jquery";
declare const $: JQueryStatic;
これは文句なしで作成されます。だから私はサラバナあなたのポストを元に戻す必要がありますと思う。