例如jquery bootstrap 一起安装
cnpm install --save jquery (--save是项目里面保存 可以在package.json中查看)
cnpm install --save bootstrap
接下来更改脚手架里面的json
现在这里更改脚手架里面的内容(每次更改完脚手架 都要重启npm)"styles": [ "styles.css", "../node_modules/_bootstrap@3.3.7@bootstrap/dist/css/bootstrap.css" ], "scripts": [ "../node_modules/_jquery@3.2.1@jquery/dist/jquery.js", "../node_modules/_bootstrap@3.3.7@bootstrap/dist/js/bootstrap.js" ],
不知道为什么刚下载下来的插件没有版本号,此时是不可用的等一会 有版本号了再开始用
引入完插件——在component.ts 文件中声明
declare var $:any;
接下来 jquery 和 bootstrarp 就可以使用了
或者使用正规的方法: cnpm install @types/bootstrap --save-dev
cnpm install @types/jquery --save-dev 在开发者模式下引入jquery和bootstrap的typescript的类型描述文件
然后引入
import * as $ from 'jquery';