template 模板引擎(js jq) art-template

Posted on 2020-09-17 13:59  嗷呜~  阅读(463)  评论(0编辑  收藏  举报

需求:

原生js 模板引擎渲染:

代码:

<select style="height: 28px;border-radius: 5px;"  class="input-md selectpicker" data-live-search="true" id="ruleSeleted" name="ruleSeleted">
</select>

 

var $jQuery = $;
<script src="${request.contextPath}/static/plugin/jquery/template-web.js"></script>

<script type="text/html" id="rule_temp">
    <option value=""></option>
    {{ each list item index}}
    <option value="{{item.ruleId}}" data-code="{{item.ruleId}}" data-name="{{item.ruleName}}" data-state="{{item.ruleState}}" data-type="{{item.ruleType}}">{{item.ruleName}}</option>
    {{/each}}
</script>
 $.ajax({
        "url":path + "XXXXX",
        "type":"POST",
        success:function(res){
            
            var enentRulehtml = template('rule_temp',{
                list:res
            })
            $('#ruleSeleted').html(enentRulehtml)
         }
})

 

中文文档地址:https://aui.github.io/art-template/zh-cn/docs/index.html

git地址:https://github.com/yanhaijing/template.js