JS把数组按时间倒序

axios({                    

            method:'get',                    

            url:this.API.requeststockchange,                    

            headers: {                        

                        Authorization: "Bearer " + getCookie("token"),  

              },                

}).then(response => {                    

            this.tableData=response.data;    

            //重点代码

             this.tableData.sort(function(a,b) {                        

                            return Date.parse(b.createTime.replace(/-/g,"/"))-Date.parse(a.createTime.replace(/-/g,"/"));                   

               });                

}).catch(err => {                    

            console.log(err);                

})






你可能感兴趣的:(JS把数组按时间倒序)