I'm currently developing a registration form using VueJS, wherein users need to input their date of birth.
My challenge is in generating a list of years starting from 1900 up to the current year within a <select>
element. Any suggestions on how I can accomplish this?
I attempted the following:
new Vue({
el: '.container',
methods: {
getCurrentYear() {
return new Date().getFullYear();
}
}
});
<div class="container">
<select id="dob">
<option value="0">Year:</option>
<option v-for="year in getCurrentYear()" :value="year">{{ year }}</option>
</select>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.16/vue.js"></script>
However, the year range always starts from 1. How can I modify the loop within the <option>
to begin from the year 1900?