在 Ionic 3/4/5 中渲染 HTML 内容 [英] Render HTML content in Ionic 3/4/5

查看:22
本文介绍了在 Ionic 3/4/5 中渲染 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>

请查看 Angular 文档了解更多信息信息.

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

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

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