bootstrap not connect to the angular 6?

2020-01-29 02:52发布

问题:

npm install bootstrap

Configure angular.json:

"styles": [
"node_modules/bootstrap/dist/css/bootstrap.min.css",
"styles.scss"
]

Import directly in src/style.css:

@import '~bootstrap/dist/css/bootstrap.min.css';

after this i got this error:

ERROR in multi ./styles/bootstrap-4/css/bootstrap.min.css ./src/styles.css Module not found: Error: Can't resolve '/Users/kobi.ktk/Documents/3yr/UI/a4app/styles/bootstrap-4/css/bootstrap.min.css' in '/Users/kobi.ktk/Documents/3yr/UI/a4app'

回答1:

In angular 6 you have to do it as bellow:

npm install --save bootstrap

Then only in src/style.css file add:

@import 'bootstrap/dist/css/bootstrap.min.css';

In angular 6 you don't have to add script to angular.json file