前端篇--html动态遍历后端list数据

Html跳转页面直接加载list数据

动态加载实现后端传的list数据

Html页面


<!DOCTYPE html>

<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <script src="jquery.min.js"></script>
</head>
        <table>
             <thead>
                <tr>
                    <th>月份</th>
                    <th>版本</th>
                    <th>业务</th>
                    <th>业务范围</th>
                    <th>数量</th>
                 </tr>
              </thead>

              <tbody class="table_node">
                    <!--动态载入数据-->
                    <!-- more data -->
              </tbody>
         /table>
    <script src="load_data.js"></script> <!--引入动态加载文件-->
</body>
</html>

Js文件load_data.js

/**

 * 自动加载规则流水信息

 */

window.onload = function () {

    $.ajax({

        type: 'GET',
        url: "http:localhost:8080/api/select_latest",
        contentType: "application/json;cherset=utf-8",
        dataType: "json",
        success: function (data)
                $('.table_node').empty()
                //取出后端传过来的list值
                var chargeRuleLogs = data.data
                //对list值进行便利
    $.each(chargeRuleLogs, function (index, n) {

               var child = "<tr>"+"<td>" + chargeRuleLogs[index].month +  "</td>"
               + "<td>" + chargeRuleLogs[index].ver + "</td>"
               + "<td>" + chargeRuleLogs[index].bizPretty + "</td>"
               + "<td>"+chargeRuleLogs[index].bizRangePretty + "</td>"
               + "<td>" + chargeRuleLogs[index].count + "</td>"+"</tr>"

                //将信息追加
                $(".table_node").append(child)
                    });
              }        
    });
}

注意:

一定要引入js文件

 

  • 14
    点赞
  • 57
    收藏
    觉得还不错? 一键收藏
  • 12
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 12
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值