使用 Angular 4 - 以下代码片段位于我的 typescript 文件中。
this.tabTitle = "Project Name: " + this.currentProjectRevision.ProjectInformation[0].ProjectName;
这会获取项目名称的值并将其与项目名称连接起来:
this.tabTitle = this.tabTitle.concat('/n' + " Quote ID: " + this.quoteInformation.CurrentProjectCustomer.QuoteId);
以上代码获取第一行代码值并将其与报价 ID: 连接起来,并添加报价 ID 的值。
运行时,输出如下。项目名称:test/n 引用ID:0000001
上述实际值附加到以下代码中。 项目名称:bvn xbn/n 报价ID:1000016
我希望报价 ID 在新行开始。
我试过输入 <br/>
, <br>
以及/n 都不会成功。它们都作为字符串添加。
到目前为止我尝试过的代码
this.tabTitle = this.tabTitle.concat('<br/>' + " Quote ID: " + this.quoteInformation.CurrentProjectCustomer.QuoteId);
this.tabTitle = this.tabTitle.concat('<br>' + " Quote ID: " + this.quoteInformation.CurrentProjectCustomer.QuoteId);
this.tabTitle = this.tabTitle.concat('/n' + " Quote ID: " + this.quoteInformation.CurrentProjectCustomer.QuoteId);
任何帮助将不胜感激。
最佳答案
您可以将类附加到具有属性 white-space: pre;
的元素。如果您使用的是 /n
,这将为您换行。
关于angular - 在 concat() 字符串中添加新行 - Angular 4,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50496780/