【发布时间】:2018-01-11 01:19:07
【问题描述】:
我尝试运行以下 npm install 但它没有解决任何问题。 npm install jquery --save npm install @types/jquery --save-dev
我在 .angular-cli.json 文件中添加了“脚本”:[“../node_modules/jquery/dist/jquery.min.js”]。
app.component.ts
import { Component } from '@angular/core';
declare var $:any;
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
title = 'jQuery works!';
onToggle(){
$('.test').slideToggle();
}
}
错误:$ 未定义
【问题讨论】:
-
你不需要 import $ from 'jquery'; stackoverflow.com/questions/39511788/…
-
你使用引导程序吗?
-
前几天我帮助了一个人。请检查链接。 stackoverflow.com/questions/45440350/…
-
您解决了这个问题吗?
标签: angular