[英]Bootstrap framework not included in the angular-cli
I have installed the bootstrap framework to the angular2 project via npm and it shows in the node-modules folder.But, the angular-cli file does not have the boostrap script as well as css. 我已经通过npm安装了bootstrap框架到angular2项目,它显示在node-modules文件夹中。但是,angular-cli文件没有boosts脚本以及css。
"apps": [
{
"root": "src",
"outDir": "dist",
"assets": [
"assets",
"favicon.ico"
],
"index": "index.html",
"main": "main.ts",
"polyfills": "polyfills.ts",
"test": "test.ts",
"tsconfig": "tsconfig.app.json",
"testTsconfig": "tsconfig.spec.json",
"prefix": "app",
"styles": [
"styles.css"
],
"scripts": [],
"environmentSource": "environments/environment.ts",
"environments": {
"dev": "environments/environment.ts",
"prod": "environments/environment.prod.ts"
}
}
],
I manually tried to add the bootstrap location css,js file in the angular-cli file and restarted,but it shows build errors.Is there any other solution to resolve this issue? 我手动尝试将bootstrap位置css,js文件添加到angular-cli文件中,然后重新启动,但显示生成错误。是否有其他解决方案可解决此问题?
此处的Angular CLI文档中有说明: https : //github.com/angular/angular-cli/wiki/stories-include-bootstrap
You need to add the css file in styles
array like below: 您需要在styles
数组中添加css文件,如下所示:
"styles": ["styles.css", "../node_modules/bootstrap/dist/css/bootstrap.css"]
If you need bootstrap js file, you can add it like follows: 如果您需要bootstrap js文件,则可以如下添加它:
"scripts": ["../node_modules/bootstrap/dist/js/bootstrap.min.js"]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.