Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/32.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何将打底确认框消息拆分为单独的行?_Javascript_Angular_Typescript_Element_Primeng - Fatal编程技术网

Javascript 如何将打底确认框消息拆分为单独的行?

Javascript 如何将打底确认框消息拆分为单独的行?,javascript,angular,typescript,element,primeng,Javascript,Angular,Typescript,Element,Primeng,谁能给我一个打破确认框的建议吗 我试过下面的代码。但它将br标记显示为字符串。还有别的办法解决这个问题吗 this.confirmationService.confirm({ message: 'CoC updated successfully' + '</br>' + ' Do you want to close or continue working with this?', icon: 'fa fa

谁能给我一个打破确认框的建议吗

我试过下面的代码。但它将br标记显示为字符串。还有别的办法解决这个问题吗

this.confirmationService.confirm({
                    message: 'CoC updated successfully' + '</br>' + ' Do you want to close or continue working with this?',
                    icon: 'fa fa-question-circle',
                    header: 'Confirm Save',
                    accept: () => {
                       this.infomessage = [];
                        this.infomessage.push({ severity: 'success', summary: '', detail: Updated Successfully' });                    },
                    reject: () => {
                        this.router.navigate(['versions']);
                    }
                });
this.confirmationService.confirm({
消息:“CoC已成功更新”+”
“+”是否要关闭或继续使用它, 图标:“fa fa问题圈”, 标题:“确认保存”, 接受:()=>{ this.infomessage=[]; this.infomessage.push({severity:'success',summary:'',detail:Updated Successfully'});}, 拒绝:()=>{ this.router.navigate(['versions']); } });
我不确定这是否有效,但您可以尝试使用DOMSanizer。修改您的代码,如下所示:

message: this.sanitizer.bypassSecurityTrustHtml(
'CoC updated successfully' + '</br>' + ' Do you want to close or continue working with this?'
)
在构造器中

constructor(private sanitizer: DomSanitizer)
当您查看。。。他们正在使用

[innerHTML]="message"

所以这可能会起作用。

是的,我通过以下步骤得到了它

第一步 我们需要将
{{message}}
移动到

<span class=\"ui-confirmdialog-message\"><pre>{{message}}</pre></span>
步骤2 我们应该在这个类
.ui confirmdialog message
中添加
空白:pre-line
。像

步骤3 如果您添加
\n
,则我们可以中断消息。例如,
message:updated successfully\n是否要关闭或继续使用此



我希望这个答案对某人有所帮助

最简单的方法是在确认对话框中添加,以便能够使用\n

例如:

this.confirmationService.confirm({
消息:“CoC已成功更新\n是否要关闭或继续使用此文件?”,
图标:“fa fa问题圈”,
标题:“确认保存”,
接受:()=>{
this.infomessage=[];
this.infomessage.push({severity:'success',summary:'',detail:Updated Successfully'});},
拒绝:()=>{
this.router.navigate(['versions']);
}
});

来源:


\n
?两者都已尝试过。但不幸的是,我对模板字符串一无所知。我已经发布了有问题的代码。我需要两个确认框在上午页。所以我不喜欢和模板一起使用。我认为它的行为类似于JavaScript警报,不允许在其中使用HTML。使用
innerHTML
代替插值绑定实际上存在一个公开的问题:但是我不喜欢使用
[innerHttml]
。我认为这是个坏主意。我会在最坏的情况下试试:)你不必。他们在代码中设置对话框的内容。我提到了这一点,因为如果不使用[innerHTML],DomSanitizer将无法工作。这是有效的(在Priming 6上测试)。然而,步骤1不是必需的。
<span class=\"ui-confirmdialog-message\"><pre>{{message}}</pre></span>
.ui-confirmdialog-message {
       white-space: pre-line;
}
this.confirmationService.confirm({
                    message: '<pre>CoC updated successfully\nDo you want to close or continue working with this?</pre>',
                    icon: 'fa fa-question-circle',
                    header: 'Confirm Save',
                    accept: () => {
                       this.infomessage = [];
                        this.infomessage.push({ severity: 'success', summary: '', detail: Updated Successfully' });                    },
                    reject: () => {
                        this.router.navigate(['versions']);
                    }
                });