简体   繁体   English

在 Angular 项目中安装 Bootstrap

[英]Installing Bootstrap in an Angular project

Good morning,早上好,

I'm a WEB Developer trainee and I'm at 5 months of training.我是一名 WEB 开发人员实习生,我正在接受 5 个月的培训。 I have to install Bootstrap in a web interface project created with Angular.我必须在使用 Angular 创建的 Web 界面项目中安装 Bootstrap。 Project that will run locally, on a server and therefore no connection to the internet and no use of CDN (content delivery network).将在服务器上本地运行的项目,因此不连接到 Internet 也不使用 CDN(内容分发网络)。 I use npm and I installed Bootstrap 4.4.1, it appears in the file "package.json" and I completed the file "angular.json" at the "style" level.我使用 npm 并安装了 Bootstrap 4.4.1,它出现在文件“package.json”中,我在“样式”级别完成了文件“angular.json”。

Translated with www.DeepL.com/Translator (free version), because I'm French and like many of my compatriots, my accent is... Anyway... :)用 www.DeepL.com/Translator 翻译(免费版),因为我是法国人,和我的很多同胞一样,我的口音是……反正……:)

you can install bootstrap in angular using npm install bootstrap command.您可以使用npm install bootstrap命令以角度安装 bootstrap。

you can read a full blog about how to install & setup bootstrap in angular, here click to full blog about this您可以阅读有关如何以角度安装和设置引导程序的完整博客,点击此处查看有关此内容的完整博客

Try adding this in your css file (after installing bootstrap via npm i bootstrap ) Dont forget ~ before bootstrap.尝试将其添加到您的 css 文件中(在通过npm i bootstrap安装 bootstrap 之后)不要忘记~在 bootstrap 之前。

@import "~bootstrap/dist/css/bootstrap.min.css";
  1. use This command line: ng add @ng-bootstrap/ng-bootstrap使用此命令行:ng add @ng-bootstrap/ng-bootstrap

  2. Check in your package.jSon in the dependencies section if the 'bootstrap' appears.如果出现“引导程序”,请在依赖项部分检查您的 package.jSon。 So you can use bootstrap in your project.所以你可以在你的项目中使用bootstrap。

  3. Con't forget to restart your server with ng serve command this way works well for me.不要忘记使用 ng serve 命令重新启动服务器,这种方式对我来说效果很好。 package.json Exemple package.json 示例

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

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