繁体   English   中英

Bootstrap在Angular 6应用程序中不起作用

[英]Bootstrap not working in Angular 6 app

我想在Angular 6应用程序中使用Bootstrap,这是我到目前为止所做的,但似乎没有任何工作:

1)使用npm安装bootstrap,jquery和popper.js。 2)在Angular.json文件中输入以下内容

"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"
    ...
]

我错过了什么。 这似乎没有成功。

在你的style.scss文件中使用import

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

并从angular.json文件中删除"node_modules/bootstrap/scss/bootstrap.scss"

首先在App上安装bootstrap:

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

然后将引导程序导入Angular中的index.html文件:

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

我希望这回答了你的问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM