1
npm install jquery — save
2
.angular-cli.json
“scripts”: [ “../node_modules/jquery/dist/jquery.min.js” ]
3
app.component.ts
import * as $ from ‘jquery’;
测试
$('body').addClass('aaa');
本文介绍如何在Angular项目中安装并使用jQuery。通过npm安装jQuery,并将其添加到angular-cli.json文件中,然后在app.component.ts中导入jQuery进行测试。
npm install jquery — save
.angular-cli.json
“scripts”: [ “../node_modules/jquery/dist/jquery.min.js” ]
app.component.ts
import * as $ from ‘jquery’;
$('body').addClass('aaa');
1539