后端字段要加@JsonFormat注解,否则前端会显示NaN
前端获取出生日期,利用vue过滤器filte将日期转换为年龄
//获取日期
<template slot-scope="scope">
{{scope.row.birthday | showAge}}
</template>
//利用filters过滤器将日期转换为年龄
filters: {
showAge(value) {
// 指定日期
let birthdays = new Date(value.replace(/-/g, "/"))
// 当前系统日期
let d = new Date();
let age = d.getFullYear() - birthdays.getFullYear() - (d.getMonth() <
birthdays.getMonth() || (d.getMonth() == birthdays.getMonth() &&
d.getDate() < birthdays.getDate()) ? 1 : 0);
return age
}
}