以Ionic 3/4呈现HTML内容 [英] Render HTML content in Ionic 3/4

查看:274
本文介绍了以Ionic 3/4呈现HTML内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

view.html

<div>{{text}}</div>

问题是文本"具有希望按原样显示的HTML,但仅显示HTML标签和文本.

The question is that 'text' has HTML that I wish to be displayed as it should but it only shows the HTML tags and text.

我该怎么做才能呈现此类内容?

What can I do to render such content?

我已经尝试了较早版本(Ionic 1/2)的解决方案,但似乎与Ionic v3无关.

I've tried the earlier version (Ionic 1/2) solutions and nothing seems to work with Ionic v3.

推荐答案

您应使用innerHTML属性绑定,如下所示:

You should use the innerHTML attribute binding like this:

<div [innerHTML]="text"></div>

请查看角度文档以了解更多信息信息.

Please take a look at the Angular docs for more information.

这篇关于以Ionic 3/4呈现HTML内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆