artTemplate template engine, the data obtained from the background is html code, whether it is rendered to the page or label, how to solve it
光陰似箭催人老,日月如移越少年。
You can use jQuery to replace tags
<script>
var data="<font color='red'>測試數(shù)據(jù)</font>";//帶有html標簽的測試數(shù)據(jù)
$('#p1').html(data);//通過html()方法將數(shù)據(jù)輸出到p中
</script>
You try it! Dude, don’t forget to introduce jQuery
Of course, native js is also possible
It’s very simple, you create a new DOM node <p id="content"></p>, then var a variable equal to this code, assign this variable to the DOM node, use jQuery method As mentioned above, the native method is
<script>
var str = "那段代碼";
document.getElementById("content").innerHTML(str);
</script>
// [3]. Use templates to generate HTML. The output is escaped by default. If not escaped, use {{#value}}
I happened to encounter this problem when I was using artTemplate recently.
Use {{@html}}
for original text output
There are risks, use with caution.
Official tutorial: https://aui.github.io/art-tem...Original text output