gpt4 book ai didi

css - Angular 7 升级后样式问题

转载 作者:行者123 更新时间:2023-12-02 03:18:13 24 4
gpt4 key购买 nike

我们已将应用程序从 Angular 5.2 升级到 7.2,但样式变得一团糟。某些元素(例如:图标和文本)之间的间距已更改、消失或减小。

升级 Angular 应用程序或以下软件包后,你们中有人遇到过类似的问题吗?

我已经将所有可能的包恢复到其暂存版本,但这并没有解决问题。

我不知道从哪里开始进行故障排除以找到问题的根源。 样式和 HTML 未更改。

我们更新了:

  • Bootstrap :从 4.1.0 到 4.3.1
  • @ng-bootstrap/ng-bootstrap:从 1.1.2 到 4.0.0
  • ngx-bootstrap:从 2.0.5 到 4.0.0

样式是来自 angular.json 的全局样式: enter image description here

我们导入使用过的 Bootstrap 组件的位置: enter image description here

package.json 如下所示:

{
"private": true,
"dependencies": {
"@angular/animations": "7.2.11",
"@angular/common": "7.2.11",
"@angular/compiler": "7.2.11",
"@angular/core": "7.2.11",
"@angular/forms": "7.2.11",
"@angular/http": "7.2.11",
"@angular/platform-browser": "7.2.11",
"@angular/platform-browser-dynamic": "7.2.11",
"@angular/platform-server": "7.2.11",
"@angular/router": "7.2.11",
"@fortawesome/angular-fontawesome": "0.3.0",
"@fortawesome/fontawesome-svg-core": "1.2.12",
"@fortawesome/free-solid-svg-icons": "5.6.3",
"@ng-bootstrap/ng-bootstrap": "4.0.0",
"@nguniversal/express-engine": "7.1.1",
"@ngx-translate/core": "11.0.1",
"@ngx-translate/http-loader": "4.0.0",
"acorn": "6.1.1",
"angular2-image-zoom": "1.2.1",
"bootstrap": "4.3.1",
"braintree-web-drop-in": "1.16.0",
"core-js": "2.6.5",
"file-saver": "2.0.1",
"font-awesome": "4.7.0",
"htmllint": "0.7.3",
"intl": "1.2.5",
"jquery": "3.3.1",
"ng-jhipster": "0.9.3",
"ng-recaptcha": "4.2.1",
"ng2-order-pipe": "0.1.5",
"ngx-bootstrap": "4.0.0",
"ngx-color-picker": "7.4.0",
"ngx-cookie": "4.1.2",
"ngx-webstorage": "3.0.2",
"popper.js": "1.14.7",
"print-js": "1.0.54",
"rxjs": "6.4.0",
"rxjs-compat": "6.4.0",
"tslib": "1.9.3",
"zone.js": "0.8.26"
},
"devDependencies": {
"@angular-devkit/build-angular": "0.13.7",
"@angular/cli": "7.3.7",
"@angular/compiler-cli": "7.2.11",
"@angular/language-service": "7.2.11",
"@types/file-saver": "2.0.0",
"@types/hammerjs": "2.0.36",
"@types/jasmine": "3.3.12",
"@types/jasminewd2": "2.0.6",
"@types/node": "11.12.0",
"codelyzer": "5.0.0",
"jasmine-core": "3.3.0",
"jasmine-spec-reporter": "4.2.1",
"karma": "4.0.1",
"karma-chrome-launcher": "2.2.0",
"karma-cli": "2.0.0",
"karma-coverage-istanbul-reporter": "2.0.5",
"karma-jasmine": "2.0.1",
"karma-jasmine-html-reporter": "1.4.0",
"node-sass": "4.11.0",
"protractor": "6.0.0",
"sort-json": "2.0.0",
"ts-node": "8.0.3",
"tslint": "5.14.0",
"typescript": "3.2.4"
}
}

最佳答案

我相信从 Angular 6 开始,preserveWhitespace 选项默认为 false。要在全局范围内再次打开它,您可以在 tsconfig.app.json 中添加一个选项:

"angularCompilerOptions": {
"preserveWhitespaces": true
}

或者,您可以在需要保留空格的任何元素上使用指令 ngPreserveWhitspaces

参见here有关它的一些(相当隐藏的)文档。

关于css - Angular 7 升级后样式问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55517902/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com