primeng - Angular使用包装器组件进行primeng p-inputnumber无法设置样式
问题描述
我是 Angular 的 PrimeNg 新手。我有一个简单的primeng p-inputnumber 组件,如下所示:
<p-inputNumber
[showButtons]="true"
[placeholder]="placeholderText"
incrementButtonIcon="fal fa-plus"
decrementButtonIcon="fal fa-minus"
[minFractionDigits]="_config?.integer ? 0 : 1"
[min]="_config?.minValue"
[max]="_config?.maxValue"
[(ngModel)]="value"
(onBlur)="onBlur()">
</p-inputNumber>
并且已经为这个组件创建了一个包装器,即上述组件的包装器并在主页组件中使用它。现在我想将样式应用于此包装器组件,而后者又应将样式应用于primeng组件。现在它没有设置。
Homepagecomponent.html
---<app-number-input class="disabled">
------<p-inputNumber>
我在 homepagecomponent.scss 中设置了以下样式
:host ::ng-deep .disabled {
background: red;
}
但是上面没有设置。谁能帮我实现我的预期?
谢谢
解决方案
你的 CSS 中需要这样的东西
:host ::ng-deep {
// you may want to specify your app element or something here to be more specific than just .disabled class
.disabled {
// tweak this list to whichever pieces of the p-inputnumber you want to have red background
.p-inputnumber,
.p-inputnumber-stacked,
.p-inputnumber-horizontal,
.p-inputnumber-vertical,
.p-inputnumber-input,
.p-inputnumber-button,
.p-inputnumber-button-up,
.p-inputnumber-button-down,
.p-inputnumber-button-icon {
background-color: red;
}
}
}
推荐阅读
- azure - 在 Azure 容器实例中使用伪 TTY?
- python - 是否有自动检测数据类型的 argparse 模块
- java - spring-boot:自动连接 2 个变量,但指向一个 bean
- node.js - 我有一个添加用户的 POST 请求。我不想两次添加同一个用户。我怎么能添加这个功能
- reactjs - 使用 React Native Web 时如何选择文件?
- javascript - 在 jQuery 语法错误属性名称中使用 CSS 包含破折号字符
- python - 全屏时禁用windows键
- jasper-reports - Jasper Studio 中的文档为空
- javascript - 使用自定义 Javascript 的 Angular 应用程序中的本机调用失败
- python - 在 Pycharm 中使用 virtualenv/virtualwrapper