【发布时间】:2022-12-17 11:49:45
【问题描述】:
我正在尝试在使用 SCSS 而不是 CSS 的 Angular 14 项目中设置 Bootstrap 5。我已经通过 npm (npm install bootstrap --save) 安装了引导程序,现在我的 package.json 文件中正确引用了它:
"dependencies": {
"@angular/animations": "^14.2.2",
"@angular/cdk": "^14.2.2",
"@angular/common": "^14.2.2",
"@angular/compiler": "^14.2.2",
"@angular/core": "^14.2.2",
"@angular/forms": "^14.2.2",
"@angular/material": "^14.2.2",
"@angular/platform-browser": "^14.2.2",
"@angular/platform-browser-dynamic": "^14.2.2",
"@angular/router": "^14.2.2",
"@popperjs/core": "^2.11.6",
"bootstrap": "^5.2.1",
"rxjs": "~7.5.0",
"tslib": "^2.3.0",
"zone.js": "~0.11.4"
},
我在我的 angular.json 文件中添加了 bootstrap.scss 文件引用:
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist/file-sharing-app.ui",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "tsconfig.app.json",
"inlineStyleLanguage": "scss",
"assets": [
"src/favicon.ico",
"src/assets"
],
"styles": [
"src/styles.scss",
"src/custom-theme.scss",
"node_modules/bootstrap/scss/bootstrap.scss"
],
"scripts": []
},
但是下面的类没有效果:
<span class="ml-3">File Sharing App</span>
我使用过的其他引导程序类都没有工作。我尝试重新启动应用程序(重新运行ng serve)。有人知道我错过了什么吗?
【问题讨论】:
标签: angular sass bootstrap-5