Sivo 悉见

6、添加三方依赖

匿名 · 更新于 2017/9/27

1、在项目根目录下执行如下代码,安装三方依赖
npm install jquery --save
npm install bootstrap --save

2、安装类型描述文件,执行如下代码
npm install @types/jquery --save-dev
npm install @types/bootstrap --save-dev

3、 安装完成后,修改src目录下的tsconfig.app.json文件,将jquery添加到types数组中,如下:

"types": [
    "jquery"
]

4、然后在项目根目录下打开文件.angular-cli.json,并添加如下代码(加粗部分),引入三方依赖
"styles": [
        "styles.css",
        "../node_modules/bootstrap/dist/css/bootstrap.css"
],
"scripts": [
        "../node_modules/jquery/dist/jquery.js",
        "../node_modules/bootstrap/dist/js/bootstrap.js"

]

5、这时就可以在项目中使用三方依赖了,如果没有生效,请重启项目服务试一下