Poo*_*sam 8 html css html5 typescript
我在typescript组件中创建一个列表项,它将显示在UI中.列表项应以单独的行显示.所以我添加了新的字符串\n如下所示.但是列表项仍然显示在同一行中.下面是代码.知道为什么它不起作用吗?
打字稿代码:
@Output() excludeDisplay: any = '';
@Output() includeDisplay: any = '';
includeValues: any = '';
excludeValues: any = '';
this.includeValues += this.merId + ',' + this.explodeStatus + '\n';
console.log("include values are "+ this.includeValues);
this.excludeValues += this.merId + ',' + this.explodeStatus + '\n';
console.log("exclude values are "+ this.excludeValues);
this.includeDisplay = this.includeValues;
this.excludeDisplay = this.excludeValues;
Run Code Online (Sandbox Code Playgroud)
Html代码:
<ul id="excludedUl" required>{{ excludeDisplay }}</ul>
<ul id="includedUl" required>{{ includeDisplay }}</ul>
Run Code Online (Sandbox Code Playgroud)
CSS代码:
#includedUl {
float: right;
width: 33%;
}
#excludedUl {
float: right;
width: 33%;
}
Run Code Online (Sandbox Code Playgroud)
Pal*_*Roy 16
需要使用固定宽度:
<div style="width: 500px;white-space: pre-line">{{property}}</div>
Run Code Online (Sandbox Code Playgroud)
在打字稿中使用 '\n' 添加新行。
Nit*_*mer 10
\n
也不会引起HTML换行符.
您需要使用<br/
>或将文本包装在块元素中.
this.includeValues += this.merId + ',' + this.explodeStatus + '<br/>';
this.excludeValues += this.merId + ',' + this.explodeStatus + '<br/>';
Run Code Online (Sandbox Code Playgroud)
要么
this.includeValues += '<div>' + this.merId + ',' + this.explodeStatus + '</div>';
this.excludeValues += '<div>' + this.merId + ',' + this.explodeStatus + '</div>';
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
30032 次 |
最近记录: |