将内容按时间排序的方法

<el-button @click="sortByTime" plain>按时间排序</el-button>
sortByTime(){       
            return this.mycomments.sort(function(a,b) {               
                let val1 = a.time
                let val2 = b.time
                return new Date(val2.replace(/-/,'/')) - new Date(val1.replace(/-/,'/'))
            });
        },
发布了11 篇原创文章 · 获赞 0 · 访问量 3617

猜你喜欢

转载自blog.csdn.net/weixin_39388536/article/details/90613604