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.
"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?
此处的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": ["styles.css", "../node_modules/bootstrap/dist/css/bootstrap.css"]
If you need bootstrap js file, you can add it like follows:
"scripts": ["../node_modules/bootstrap/dist/js/bootstrap.min.js"]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.