search

Home  >  Q&A  >  body text

javascript - artTemplate template engine, the data obtained from the background is how the html code is rendered to the page

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

大家讲道理大家讲道理2709 days ago1422

reply all(4)I'll reply

  • 仅有的幸福

    仅有的幸福2017-07-05 11:05:48

    You can use jQuery to replace tags

    <script>
        var data="<font color='red'>测试数据</font>";//带有html标签的测试数据
        $('#p1').html(data);//通过html()方法将数据输出到p中
    </script>

    You try it! Dude, don’t forget to introduce jQuery
    Of course, native js is also possible

    reply
    0
  • 天蓬老师

    天蓬老师2017-07-05 11:05:48

    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>

    reply
    0
  • 巴扎黑

    巴扎黑2017-07-05 11:05:48

    // [3]. Use templates to generate HTML. The output is escaped by default. If not escaped, use {{#value}}

    reply
    0
  • 欧阳克

    欧阳克2017-07-05 11:05:48

    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

    reply
    0
  • Cancelreply