从同一个组件打开时,如何以 2 种不同的方式 CSS 样式 KendoUI-Dialog 标题栏?
How to CSS style KendoUI-Dialog titlebar in 2 different ways when opening from the same Component?
我在设置 KENDO UI 对话框时遇到问题:
我有一个组件,我们称它为 WatComponent。在里面,
- 如果用户单击 "Forbidden" 按钮,我想要 warning 样式的对话框到 pop-up,带有 yellow/orange 彩色标题栏,
- 如果用户单击 "DANGER" 按钮,我想要 error 样式的对话框 pop-up,带有红色标题栏。
如果我通过 DialogService 打开对话框:
const dialogRef = this.dialogService.open({
title: this.danger ? 'DANGER!' : 'Warning!',
content: WatDialogComponent
});
const userInfo = dialogRef.content.instance;
userInfo.danger = this.danger;
如何应用两种不同的 CSS 样式(以任何方式)使从同一组件打开时标题栏显示不同的颜色?
我试过了
- 将 class 添加到
<div kendoDialogContainer class="myTitlebarClass"></div>
但当然,我没想到它会起作用(它没有)。
- 赋予 属性
danger
一些功能以将其传递给标题栏,但不幸的是,它仅影响 WatDialogComponent
内的标题栏,我想访问其中一个标题栏走出去。
- 在
DialogRef
中寻找 属性 让我这样做。
是否有我缺少的直接解决方案?如果没有,是否有解决方法?
查看 DialogRef API
https://www.telerik.com/kendo-angular-ui/components/dialogs/api/DialogRef/
它包括 ComponentRef 可用于获取主机元素并添加 class:
this.dialog = this.dialogService.open({
title: 'Warning',
content: 'Warning'
});
this.dialog.dialog.location.nativeElement.classList.add('warning');
我在设置 KENDO UI 对话框时遇到问题:
我有一个组件,我们称它为 WatComponent。在里面,
- 如果用户单击 "Forbidden" 按钮,我想要 warning 样式的对话框到 pop-up,带有 yellow/orange 彩色标题栏,
- 如果用户单击 "DANGER" 按钮,我想要 error 样式的对话框 pop-up,带有红色标题栏。
如果我通过 DialogService 打开对话框:
const dialogRef = this.dialogService.open({
title: this.danger ? 'DANGER!' : 'Warning!',
content: WatDialogComponent
});
const userInfo = dialogRef.content.instance;
userInfo.danger = this.danger;
如何应用两种不同的 CSS 样式(以任何方式)使从同一组件打开时标题栏显示不同的颜色?
我试过了
- 将 class 添加到
<div kendoDialogContainer class="myTitlebarClass"></div>
但当然,我没想到它会起作用(它没有)。 - 赋予 属性
danger
一些功能以将其传递给标题栏,但不幸的是,它仅影响WatDialogComponent
内的标题栏,我想访问其中一个标题栏走出去。 - 在
DialogRef
中寻找 属性 让我这样做。
是否有我缺少的直接解决方案?如果没有,是否有解决方法?
查看 DialogRef API https://www.telerik.com/kendo-angular-ui/components/dialogs/api/DialogRef/ 它包括 ComponentRef 可用于获取主机元素并添加 class:
this.dialog = this.dialogService.open({
title: 'Warning',
content: 'Warning'
});
this.dialog.dialog.location.nativeElement.classList.add('warning');