angular-cli: 如何添加外部库 (jquery, bootstrap)
angular-cli: how to add external libraries (jquery, bootstrap)
目前我要做的事情:
- 安装本地库
npm install bootstrap
和 npm install jquery
- 创建文件夹
src\assets
- 复制 node_modules\bootstrap 和 node_modules\jquery
中的所有文件
在index.html
<script src="assets/jquery/jquery.min.js"></script>
<script src="assets/bootstrap/js/bootstrap.min.js"></script>
<link href="assets/bootstrap/css/bootstrap.min.css" rel="stylesheet">
有什么更好的方法吗?
看完你就会明白:
https://github.com/angular/angular-cli#3rd-party-library-installation
基本上你只需要将它添加到 angular-cli.json
文件中的 scripts
属性 (apps[0]
).
"scripts": [
"../node_modules/jquery/dist/jquery.js",
"../node_modules/tether/dist/js/tether.js",
"../node_modules/bootstrap/dist/js/bootstrap.js"
]
目前我要做的事情:
- 安装本地库
npm install bootstrap
和npm install jquery
- 创建文件夹
src\assets
- 复制 node_modules\bootstrap 和 node_modules\jquery 中的所有文件
在index.html
<script src="assets/jquery/jquery.min.js"></script>
<script src="assets/bootstrap/js/bootstrap.min.js"></script>
<link href="assets/bootstrap/css/bootstrap.min.css" rel="stylesheet">
有什么更好的方法吗?
看完你就会明白:
https://github.com/angular/angular-cli#3rd-party-library-installation
基本上你只需要将它添加到 angular-cli.json
文件中的 scripts
属性 (apps[0]
).
"scripts": [
"../node_modules/jquery/dist/jquery.js",
"../node_modules/tether/dist/js/tether.js",
"../node_modules/bootstrap/dist/js/bootstrap.js"
]