[转]如何在Angular4中引入jquery

本文转自:https://blog.csdn.net/home_zhang/article/details/77992734

1、anjq是我的项目名称:

在anjq目录下打开dos命令窗口,然后依次执行如下命令:

npm install --save jquery

npm install @types/jquery --save
如图:

 

2、执行完命令之后,会发现配置文件package.json中会多出配置信息:

"@types/jquery":"^3.2.12",
"jquery":"^3.2.1",

 

3、在组件中引入jquery即可使用:

import * as $ from 'jquery';

$("#btnTest").on('click',function(){
alert('hi,jquery!');
});

 

 

---------------------
作者:叮咚侠
来源:CSDN
原文:https://blog.csdn.net/home_zhang/article/details/77992734
版权声明:本文为博主原创文章,转载请附上博文链接!

 

posted on 2018-10-30 17:58  freeliver54  阅读(140)  评论(0编辑  收藏  举报

导航