Angular项目中引入jQuery

 

npm install --save jquery

npm install @types/jquery --save

 

在对应的组件中引入

import * as $ from "jquery";

 在整个项目中一次声明,不用重复引入的方式:

.angular-cli.json文件中添加

{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "project": {
    "name": "map"
  },
  "apps": [
    {
     ...
      "styles": [
       ...
      ],
      "scripts": [
        "../node_modules/jquery/dist/jquery.js",
       ...
      ],
      ...
    }
  ],
}

 

posted @ 2019-03-05 11:05  Viola_left  阅读(3108)  评论(0编辑  收藏  举报