首页 > 解决方案 > Angular 2 中的 PrimeNG 样式问题

问题描述

我正在尝试使用 PrimeNG 的日历组件,但样式不起作用。这些是我采取的所有步骤:

我使用以下命令安装了 PrimeNG:npm i primeng

我在 app.module.ts 中导入了 CalendarModule:

import {CalendarModule} from 'primeng/calendar';

并将其放入我的导入[]:

imports: [
    BrowserModule,
    AppRoutingModule,
    HttpClientModule,
    ReactiveFormsModule,
    FormsModule,
    NgbModule,
    SocketIoModule.forRoot(config),
    BrowserAnimationsModule,
    CalendarModule,
  ],

我将样式表添加到我的 angular.json 中:

        "styles": [
          "src/styles.css",
          "../node_modules/primeng/resources/themes/bootstrap/theme.css" ,
          "../node_modules/primeng/resources/primeng.css",
        ],

我在我的一个组件中插入了一个 p 日历,如下所示:

<label for="publishedAt">Published At:</label>
<p-calendar
    [(ngModel)]="news.publishedAt"
    name="publishedAt"
    id="publishedAt"
    required
    #publishedAt="ngModel"
    showTime="true"
    hourFormat="12"
>
</p-calendar>

但我的日历是这样的:

坏日历

有什么我错过的吗?

标签: cssangularnpmprimengprimeng-calendar

解决方案


推荐阅读