//vue实例 var vm = new Vue({ el: '#box', data: { }, methods: { }, filters: { Time: function (time) { var date2 = new Date(); var year1 = parseInt(time.substr(0, 4)); var month1 = parseInt(time.substr(5, 2)); var day1 = parseInt(time.substr(8, 2)); var year2 = date2.getFullYear(); var month2 = date2.getMonth() + 1; var day2 = date2.getDate(); var date1 = new Date(year1, month1 - 1, day1); var date2 = new Date(year2, month2 - 1, day2); var timeX = date1.getTime() - date2.getTime(); if( Math.abs(timeX) < 24 * 60 * 60 * 1000 ) { return "今天" + time.substr(11, 5); } else if ( timeX > 0 && timeX < 48 * 60 * 60 * 1000 ) { return "明天" + time.substr(11, 5); } else if ( timeX < 0 && timeX > 0 - 48 * 60 *60 * 1000) { return "昨天" + time.substr(11, 5); } else { return time.substr(0, 16); } } } });