Angular material 日期选择器 - 产品中的空白弹出窗口
Angular material datepicker - blank popup in prod
不确定我错过了什么。当我 运行 在我的本地使用 ng build 和 ng serve
时,这很好用
但是当我转向生产时,它开始表现得像这样。然后我尝试使用 ng build --prod
和 ng serve --prod
在本地重现。现在我也可以在本地重现这个问题了。
我想要的:日期选择器弹出窗口应该以正确的样式出现并且应该能够 select 日期
现在的工作:在本地它正在使用 ng build 和 ng serve
问题是什么:在产品中(或使用 ng build --prod
和 ng serve --prod
),弹出窗口显示为空。请下图
我尝试过的:经过研究,我发现了一些尝试使用 ng serve --prod --build-optimizer=false
的建议,也尝试过在 angular.json
中制作 "buildOptimizer": false
错误:当我点击日期选择器图标时,我可以在下面的错误
TypeError: Cannot read property 'getElementsByClassName' of
请告诉我调试此问题需要哪些更多信息。我正在考虑创建一个 stackblitz,但它似乎在 stackblitz 中工作。
package.json:
"dependencies": {
"@angular/animations": "^7.0.3",
"@angular/cdk": "^7.0.3",
"@angular/common": "~7.0.0",
"@angular/compiler": "~7.0.0",
"@angular/core": "~7.0.0",
"@angular/flex-layout": "^7.0.0-beta.19",
"@angular/forms": "~7.0.0",
"@angular/http": "~7.0.0",
"@angular/material": "^7.0.3",
"@angular/material-moment-adapter": "^7.3.4",
"@angular/platform-browser": "~7.0.0",
"@angular/platform-browser-dynamic": "~7.0.0",
"@angular/router": "~7.0.0",
"@swimlane/ngx-charts": "^10.1.0",
"angular-google-charts": "^0.1.3",
"bootstrap": "^4.1.3",
"chart.js": "^2.8.0",
"core-js": "^2.5.4",
"dotenv": "^7.0.0",
"hammerjs": "^2.0.8",
"jquery": "^3.3.1",
"moment": "^2.24.0",
"ng-pick-datetime": "^5.2.6",
"ng2-charts": "^2.0.3",
"ng2-tooltip-directive": "^2.1.8",
"ng4-charts": "^1.0.2",
"ngx-cookie-service": "^2.1.0",
"rxjs": "~6.3.3",
"rxjs-compat": "^6.3.3",
"zone.js": "~0.8.26"
},
"devDependencies": {
"@angular-devkit/build-angular": "^0.11.4",
"@angular/cli": "~7.0.2",
"@angular/compiler-cli": "~7.0.0",
"@angular/language-service": "~7.0.0",
"@types/jasmine": "~2.8.8",
"@types/jasminewd2": "~2.0.3",
"@types/jquery": "^3.3.29",
"@types/node": "~8.9.4",
"codelyzer": "~4.5.0",
"jasmine-core": "~2.99.1",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~3.0.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.1",
"karma-jasmine": "~1.1.2",
"karma-jasmine-html-reporter": "^0.2.2",
"ngx-spec": "^2.0.0",
"protractor": "~5.4.0",
"ts-node": "~7.0.0",
"tslint": "~5.11.0",
"typescript": "~3.1.1"
}
html:
<mat-form-field>
<mat-label>From Date</mat-label>
<input [value]="date.value" matInput [matDatepicker]="summBoardFromDatePicker" placeholder="From Date" [(ngModel)]="summBoardFromDate">
<mat-datepicker-toggle matSuffix [for]="summBoardFromDatePicker"></mat-datepicker-toggle>
<mat-datepicker #summBoardFromDatePicker></mat-datepicker>
</mat-form-field>
似乎是 material 日期选择器的缺陷。不是解决方案,而是对我有用的解决方法。
您可以尝试在 angular.json
中进行以下更改吗
"optimization": false
"aot": false
"buildOptimizer": false
不确定我错过了什么。当我 运行 在我的本地使用 ng build 和 ng serve
时,这很好用但是当我转向生产时,它开始表现得像这样。然后我尝试使用 ng build --prod
和 ng serve --prod
在本地重现。现在我也可以在本地重现这个问题了。
我想要的:日期选择器弹出窗口应该以正确的样式出现并且应该能够 select 日期
现在的工作:在本地它正在使用 ng build 和 ng serve
问题是什么:在产品中(或使用 ng build --prod
和 ng serve --prod
),弹出窗口显示为空。请下图
我尝试过的:经过研究,我发现了一些尝试使用 ng serve --prod --build-optimizer=false
的建议,也尝试过在 angular.json
"buildOptimizer": false
错误:当我点击日期选择器图标时,我可以在下面的错误
TypeError: Cannot read property 'getElementsByClassName' of
请告诉我调试此问题需要哪些更多信息。我正在考虑创建一个 stackblitz,但它似乎在 stackblitz 中工作。
package.json:
"dependencies": {
"@angular/animations": "^7.0.3",
"@angular/cdk": "^7.0.3",
"@angular/common": "~7.0.0",
"@angular/compiler": "~7.0.0",
"@angular/core": "~7.0.0",
"@angular/flex-layout": "^7.0.0-beta.19",
"@angular/forms": "~7.0.0",
"@angular/http": "~7.0.0",
"@angular/material": "^7.0.3",
"@angular/material-moment-adapter": "^7.3.4",
"@angular/platform-browser": "~7.0.0",
"@angular/platform-browser-dynamic": "~7.0.0",
"@angular/router": "~7.0.0",
"@swimlane/ngx-charts": "^10.1.0",
"angular-google-charts": "^0.1.3",
"bootstrap": "^4.1.3",
"chart.js": "^2.8.0",
"core-js": "^2.5.4",
"dotenv": "^7.0.0",
"hammerjs": "^2.0.8",
"jquery": "^3.3.1",
"moment": "^2.24.0",
"ng-pick-datetime": "^5.2.6",
"ng2-charts": "^2.0.3",
"ng2-tooltip-directive": "^2.1.8",
"ng4-charts": "^1.0.2",
"ngx-cookie-service": "^2.1.0",
"rxjs": "~6.3.3",
"rxjs-compat": "^6.3.3",
"zone.js": "~0.8.26"
},
"devDependencies": {
"@angular-devkit/build-angular": "^0.11.4",
"@angular/cli": "~7.0.2",
"@angular/compiler-cli": "~7.0.0",
"@angular/language-service": "~7.0.0",
"@types/jasmine": "~2.8.8",
"@types/jasminewd2": "~2.0.3",
"@types/jquery": "^3.3.29",
"@types/node": "~8.9.4",
"codelyzer": "~4.5.0",
"jasmine-core": "~2.99.1",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~3.0.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.1",
"karma-jasmine": "~1.1.2",
"karma-jasmine-html-reporter": "^0.2.2",
"ngx-spec": "^2.0.0",
"protractor": "~5.4.0",
"ts-node": "~7.0.0",
"tslint": "~5.11.0",
"typescript": "~3.1.1"
}
html:
<mat-form-field>
<mat-label>From Date</mat-label>
<input [value]="date.value" matInput [matDatepicker]="summBoardFromDatePicker" placeholder="From Date" [(ngModel)]="summBoardFromDate">
<mat-datepicker-toggle matSuffix [for]="summBoardFromDatePicker"></mat-datepicker-toggle>
<mat-datepicker #summBoardFromDatePicker></mat-datepicker>
</mat-form-field>
似乎是 material 日期选择器的缺陷。不是解决方案,而是对我有用的解决方法。
您可以尝试在 angular.json
"optimization": false
"aot": false
"buildOptimizer": false