[英]How to adjust the width of the toastr message in Angular
您可以使用本機類,即toast-top-full-width
或toast-bottom-full-width
<toaster-container toaster-options="{
'time-out': 2500,
'close-button':false,
'position-class':'toast-bottom-full-width'
}"></toaster-container>
作為替代方案,您還可以通過position-class
應用自定義 class 並在 CSS 中定義 class。
<toaster-container toaster-options="{
'time-out': 2500,
'close-button':false,
'position-class':'my-own-toastr-class'
}"></toaster-container>
CSS:
.my-own-toastr-class {
width: 100%;
}
評論澄清后更新:
從文檔:
設置個別選項
success
,error
,info
,warning
take (message, title, ToastConfig) 傳遞一個選項 object 來替換任何默認選項。
例子:
this.toastrService.error('everything is broken', 'Major Error', {
timeOut: 3000,
});
因此,在您的情況下,例如:
this.toastrService.error(
'This is an error message to be displayed<br> please log back','',
{ enableHtml: true,
position-class:'toast-bottom-full-width'
}
).
或者使用您自己的自定義 class:
this.toastrService.error(
'This is an error message to be displayed<br> please log back','',
{ enableHtml: true,
position-class:'my-own-toastr-class'
}
).
請在https://www.npmjs.com/package/ngx-toastr的選項下查看更多信息。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.