import jquery in angular4

≯℡__Kan透↙ 提交于 2019-11-29 02:30:29

Try this

import * as $ from 'jquery/dist/jquery.min.js';

Install jquery package using npm following is the code to install jquery

npm install jquery --save

Add types

npm install --save-dev @types/jquery

Add scripts to angular-cli.json

"apps": [{
  "scripts": [
    "../node_modules/jquery/dist/jquery.min.js", // check your ref path it might be different.
  ],
}]

In component, you need to add

declare var jquery:any;
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!