view.html
<div>{{text}}</div>
问题是' text‘有HTML,我希望它能像应该显示的那样显示出来,但它只显示HTML标记和文本。
我怎样才能呈现这些内容呢?
我已经尝试过早期版本(Ionic 1/2)的解决方案,但似乎没有任何东西适用于Ionic v3。
发布于 2017-06-26 12:37:36
发布于 2019-05-14 12:40:26
如果你想把它写在段落中,你可以通过
<p><span [innerHTML]="htmlObject"></span></p>
<p><span>"{{title}}" is the <i>interpolated</i> title.</span></p>
<p>"<span [innerHTML]="title"></span>" is the <i>property bound</i> title.</p>
<p><img src="{{heroImageUrl}}"> is the <i>interpolated</i> image.</p>
<p><img [src]="heroImageUrl"> is the <i>property bound</i> image.</p>发布于 2021-09-12 18:57:40
这个解决方案可以工作,但是有些css不能在html中工作。就像我们从后端获得了正确的数据,但不适用于innerhtml。
https://stackoverflow.com/questions/44759693
复制相似问题