Angular Material弹窗打开时渲染中断问题求助
Angular Material弹窗渲染异常问题
- 刷新页面后点击按钮打开
ContractCreatorDialogComponent时,弹窗渲染中途停止,仅显示部分图标内容;点击页面任意按钮后渲染才继续,弹窗组件的ngOnInit钩子也仅在此时触发。 - 导航到其他页面再返回后点击按钮,弹窗可正常显示。
- 已剥离组件逻辑和样式仍未定位问题原因,控制台无报错信息。
- 升级Angular 15后问题消失,怀疑是依赖包或Angular核心库版本导致的兼容性问题。
页面HTML(MyContractsComponent.html)
<mat-accordion> <div class="page-header margin-top"> <button (click)="openContractCreationDialog()"> <mat-icon>add</mat-icon> <span class="button-text">asd</span> </button> </div> </mat-accordion>
组件代码
openContractCreationDialog() { const dialogRef = this.dialog.open(ContractCreatorDialogComponent, {});; }
ContractCreatorDialogComponent
@Component({ selector: 'app-contract-creator-dialog', template: ` <h3 class="title" mat-dialog-title> <mat-icon class="middle">keyboard_backspace</mat-icon> </h3> `, }) export class ContractCreatorDialogComponent { constructor( ) {} }
package.json依赖版本
{ "@angular/animations": "~15.0.3", "@angular/cdk": "^15.0.2", "@angular/common": "~15.0.3", "@angular/compiler": "~15.0.3", "@angular/core": "~15.0.3", "@angular/forms": "~15.0.3", "@angular/material": "^15.0.2", "@angular/material-luxon-adapter": "^15.0.3", "@angular/platform-browser": "~15.0.3", "@angular/platform-browser-dynamic": "~15.0.3", "@angular/router": "~15.0.3", "@jsier/retrier": "^1.2.4", "@ngx-loading-bar/core": "^6.0.2", "@ngx-loading-bar/router": "^6.0.2", "@ngx-translate/core": "^14.0.0", "@ngx-translate/http-loader": "^7.0.0", "@tailwindcss/forms": "^0.5.3", "@tailwindcss/typography": "^0.5.8", "angular2-text-mask": "^9.0.0", "cypress": "^12.0.2", "cypress-keycloak-commands": "^1.2.0", "iban": "0.0.14", "jwt-decode": "^3.1.2", "keycloak-js": "^19.0.3", "luxon": "^3.1.1", "ngx-cacheable": "^1.4.1", "ngx-cookie-service": "^15.0.0", "ngx-pagination": "^6.0.3", "ngx-ui-loader": "^13.0.0", "pretty-quick": "^3.1.3", "rxjs": "~7.6.0", "text-mask-addons": "^3.8.0", "tslib": "^2.4.1", "zone.js": "~0.12.0" }
内容的提问来源于stack exchange,提问作者ForestG
相关产品推荐
相关产品推荐

