Bootstrap not working in Angular 6 app

亡梦爱人 提交于 2019-12-23 15:54:18

问题


I want to make use of Bootstrap in an Angular 6 app and here is what I have done so far but nothing seems to be working out:

1) Installed bootstrap, jquery and popper.js using npm. 2) Entered the following in the Angular.json file

"styles": [
    "src/styles.scss",
    "node_modules/bootstrap/scss/bootstrap.scss"
],
"scripts": [
    "node_modules/jquery/dist/jquery.slim.min.js",
    "node_modules/popper.js/dist/umd/popper.min.js",
    "node_modules/bootstrap/dist/js/bootstrap.min.js"
    ...
]

Am I missing something. This doesn't seems to work out.


回答1:


in your style.scss files use import

@import "node_modules/bootstrap/scss/bootstrap.scss"

and remove "node_modules/bootstrap/scss/bootstrap.scss" from angular.json file




回答2:


First install bootstrap to the App:

npm install bootstrap@latest --save (flag is optional)

Then import the bootstrap to the index.html file in Angular:

@import '~bootstrap/css/bootstrap.css'; (~ means the node_Modules)

I hope this answers your question.



来源:https://stackoverflow.com/questions/51870386/bootstrap-not-working-in-angular-6-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!