I looked at one of the answers and tried to apply it, but then I realized it didn't work and I tried numerous things like using Vuex to calculate the years before I used it, but nothing worked.
Generate Years from 1900 to current year with VueJS
Property or method "value" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property. See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.
Like I said, I tried using Vuex and trying to call it on the beforeCreate hook, but it didn't work.
<template>
<md-field md-clearable>
<label for="year">Year</label>
<md-select v-model="year" name="year" id="year">
<md-option :v-for="value in values" value="value">
{{ value }}
</md-option>
</md-select>
</md-field>
</template>
<script>
export default {
name: 'Component',
data () {
year: null
},
computed: {
values () {
const year = new Date().getFullYear()
return Array.from({length: year - 1900}, (value, index) => 1901 + index)
}
}
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style lang="scss" scoped>
</style>
I am expecting the dropdown to have years value instead of it being null and giving an error message. I also tried to rename the values, but it doesn't have to do anything with that. It's a really weird bug. I am seriously wondering if it's caused by vue.js itself.
year
is not defined and you're using it inv-model
– Steven B.data(){ return { myyear: null }});
– Steven B.