0👍
I think there is a time when watch function run, this.$refs[this.letter]
is not available yet. So you might want to check:
watch: {
letter () {
if (this.letter && this.$refs[this.letter]) {
const element = this.$refs[this.letter][0]
this.scroll.scrollToElement(element)
}
}
}
Your cities
has different ref, you don’t need to access [0] element
watch: {
letter () {
if (this.letter && this.$refs[this.letter]) {
const element = this.$refs[this.letter]
this.scroll.scrollToElement(element)
}
}
}
- [Vuejs]-Vue components not reactive to change in array
- [Vuejs]-Vue router and recieving data from store
Source:stackexchange.com