Answer the question
In order to leave comments, you need to log in
Why Cannot read property 'classList' of undefined?
Hello, I'm listening to an event in a component and adding/removing a class from an element. The class is added and removed fine, but in the console the error is "Cannot read property 'classList' of undefined"
Here is the code:
created() {
eventEmitter.$on('checkIfPickingStart', () => {
const target = this.$refs['compareBlock']
if (!this.currentSide) target.classList.add('pickingNotYetStarted')
setTimeout(() => (target.classList.remove('pickingNotYetStarted')), 1000)
})
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question