如何将字符串转换为Mithril中的HTML元素? [英] How to convert a string into a HTML element in Mithril?

查看:143
本文介绍了如何将字符串转换为Mithril中的HTML元素?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有一个字符串< span class =msg>文本出现在这里< / span> 。我需要将此字符串用作HTML元素我的网页。如何做到这一点的任何想法?

Suppose I have a string <span class="msg">Text goes here</span>.I need to use this string as a HTML element in my webpage. Any ideas on how to do it?

推荐答案

Mithril提供 m.trust 这个方法。在您想要HTML输出的视图中,写 m.trust('< span class =msg>文本转到这里< / span>')你应该排序。

Mithril provides the m.trust method for this. At the place in your view where you want the HTML output, write m.trust( '<span class="msg">Text goes here</span>' ) and you should be sorted.

这篇关于如何将字符串转换为Mithril中的HTML元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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