Icareabout
2021-06-27 00:11
采纳率: 100%
浏览 34
已采纳

ajax获取到json数据按照时间最新的排序在最上面

ajax获取到json数据按照时间最新的排序在最上面

 

$.ajax({  
		type: "GET",
		url:"https://api.doctorxiong.club/v1/fund/detail",  
		dataType : "json", 
		data: {"code":code},
		headers : {"token":token},
		success : function(data){
			$('#manager').append(data.data.manager);
			$('#type').append(data.data.type);
			$('#buyMin').append(data.data.buyMin);
			$('#name').append(data.data.name);
			 //$('#stockLists').append(data.data.stockList);

            var html = '';

            for (var i = 0; i < data.data.netWorthData.length; i++) {
                html += '<tr><td>' + data.data.netWorthData[i].join('</td><td>') +'</td></tr>';
            }
           $('#lslList').append(html)
		},
		error: function(data){ 
			alert('数据访问异常');
			console.log('提示:数据访问异常'); 
			} ,
	});
<table class="layui-table" lay-size="lg">
				<thead class="bg">
					<tr>
					<th>日期</th>
					<th>单位净值</th>
					<th>净值涨幅</th>
					<th>每份分红</th>
					</tr>
				</thead>
				<tbody id="lslList">
				</tbody>
			
			</table>

https://api.doctorxiong.club/v1/fund/detail?code=010066

 

用上面的代码  获取到的数据是下面这样的,怎么按照时间排序

 

下面是json数据,需要吧netWorthData里面的数据按照时间最新的排在最上面

{"code":200,"message":"操作成功","data":{"code":"010066","name":"方正富邦中证500指数增强A","type":"指数型","expectWorthDate":"2021-06-25 15:00:00","netWorthData":[["2020-12-02","1.0","0",""],["2020-12-04","1.0","0",""],["2020-12-10","1.0001","0",""]]},"meta":"010066"}

3条回答 默认 最新

相关推荐 更多相似问题