<template>
    <div class="role" :style="backgroundImg">
    
    </div>
</template>

<script>
  export default{
     data(){
      return {
         teacherBirthday:'',//出生年月日
         teacherAge:'',//年龄
        }
    },
    methods:{
//      判断用户的年龄
      getAge(){
        let birthdays = new Date(this.teacherBirthday.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);
        this.teacherAge = age;
      },
    }
   }
</script>

 

Logo

前往低代码交流专区

更多推荐