getAge(){
let birthdays = new Date(出生日期.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);
console.log(age)
},
10-02
2142
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
12-11
03-20
291
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
03-24
1942
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)