如何解决ngx-datepicker 标头为空
我正在尝试使用 ngx-datepicker,但无论我做什么,标题(datepicker 导航部分)都是空的。
预期结果:
https://i.stack.imgur.com/4dBOO.png
当前结果:
https://i.stack.imgur.com/UMjnY.png
https://i.stack.imgur.com/yhpOu.png
我的日期选择器组件代码:
-
模板代码:
<ngb-datepicker #dp [(ngModel)]="model" (navigate)="date = $event.next"></ngb-datepicker>
-
component.ts
import { Component,OnInit } from '@angular/core'; import {NgbCalendar,NgbDateStruct} from '@ng-bootstrap/ng-bootstrap'; @Component({ selector: 'app-date-picker',templateUrl: './date-picker.component.html',styleUrls: ['./date-picker.component.scss'] }) export class DatePickerComponent implements OnInit { model: NgbDateStruct; date: {year: number,month: number}; constructor(private calendar: NgbCalendar) { } ngOnInit(): void { } }
-
依赖:
"@angular/animations": "~11.1.2","@angular/common": "~11.1.2","@angular/compiler": "~11.1.2","@angular/core": "~11.1.2","@angular/forms": "~11.1.2","@angular/platform-browser": "~11.1.2","@angular/platform-browser-dynamic": "~11.1.2","@angular/localize": "11.0.9","@angular/router": "~11.1.2","@ng-bootstrap/ng-bootstrap": "^9.1.0","@ngx-translate/core": "^13.0.0","@ngx-translate/http-loader": "^6.0.0","bootstrap-with-rtl": "^1.0.3","ngx-pagination": "^5.0.0","ngx-select-ex": "^6.0.2","ngx-webstorage": "^7.0.1","bootstrap": "^4.5.3","rxjs": "~6.6.0","tslib": "^2.0.0","zone.js": "~0.11.3"
编辑:
这是该问题的最小再现:
https://stackblitz.com/edit/angular-ivy-w83mcv?file=src/app/app.component.ts
解决方法
运行npm install @angular/localize
后解决
然后将 import '@angular/localize/init';
添加到 polyfills.ts
我在这里看到,也许这个问题的标签不正确,因为它不是 ngx-bootstrap 库,而是 ng-bootstrap
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。