我用的是角5和ngx-烤面包圈。我使用了以下代码,它将HTML与消息一起呈现,比如:Hi<b>Hello</b>,这是不需要的。
this.toastr.warning("Hi<b>Hello</b>");另外,我使用了以下代码,它没有控制台错误,也没有任何输出(弹出):
this.toastr.show("<font color=\"red\">Hi<b>Hello</b></red></font>",null,{
disableTimeOut: true,
tapToDismiss: false,
closeButton: true,
positionClass:'bottom-left',
enableHtml:true
});如何在ngx中启用HTML,使消息看起来像: hiHello
发布于 2018-10-31 07:04:49
按参数的顺序更改配置,
this.toastr.show('<font color=\"red\">Hi<b>Hello</b></red></font>"',
'title' , {
enableHtml: true,
closeButton: true,
timeOut: 10000
});发布于 2022-07-01 09:34:35
我解决了这个问题,如下所示,您可以设置IndividualConfig这些设置。
export class NotificationService {
public toastrConfig: Partial<IndividualConfig> = {
timeOut: 20000,
extendedTimeOut: 20000,
enableHtml: true
};
constructor(private notifyService: ToastrService) {
}
setNotification(type: MessageType, message?: string, statusCode?: number, panelName?: string, err?: any) {
switch (type) {
case MessageType.Success:
this.notifyService.success(message ? message : 'Başarılı: .', "İşlem Başarılı Olmuştur");
break;
case MessageType.Info:
this.notifyService.info(message ? message : 'Uyarı: .', panelName);
break;
case MessageType.Danger:
let exceptionMessage = err === undefined ? "" : err;
if (panelName) {
exceptionMessage += '<div style="margin-bottom: 4px">Panel adı: <span style="font-weight: bold">' + panelName + '</span> </div>';
}
if (statusCode) {
exceptionMessage += 'Durum kodu: ' + statusCode + '<br>';
}
if (!message) {
exceptionMessage += 'İşlem başarısız.';
} else {
exceptionMessage += message;
}
this.notifyService.error(exceptionMessage, panelName);
break;
default:
break;
}
}[stackblitz1
https://stackoverflow.com/questions/53077782
复制相似问题