gpt4 book ai didi

angular - 在 snackbar Angular 4 中添加换行符

转载 作者:行者123 更新时间:2023-12-02 13:45:50 27 4
gpt4 key购买 nike

我想添加带有我提供的正确换行符的多行文本消息。

  this.sampleStringErrorMsg = 'The sample is not valid:\n' +
'- The key and key value are required in the sample.\n ' +
'- The delimiter must be entered when the sample contains several key-value pairs.\n' +
'- The delimiter must not be equal to the key or key value.\n';

sampleStringErrorMsg 是我在 snackbar 中显示的文本。现在, snackbar 从文本中省略 \n 并对齐整个消息,如下图所示 enter image description here

最佳答案

我刚刚添加了空白:预换行

//ts

const msg: string = `Registration successful. \n Please, confirm your email`;   
this._snackBar.open(msg, '', {
duration: 8000,
panelClass: ['success-snackbar']
});

//css

.success-snackbar {
background: #1fcd98;
white-space: pre-wrap
}

关于angular - 在 snackbar Angular 4 中添加换行符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49403910/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com