Answer the question
In order to leave comments, you need to log in
Nuxt.js and $ref, why doesn't it see my ref?
mounted() {
let timer;
window.addEventListener('scroll', () => {
if(timer) clearTimeout(timer);
timer = setTimeout(() => {
let testHeight = this.$refs.testElem.offsetHeight;
});
});
}
Answer the question
In order to leave comments, you need to log in
Once it works, just check this.$ref.testElem for existence. And do not forget to delete handlers in beforeDestroy, otherwise the browser will send you events to the destroyed components :)
show the code from the elements in the template
or looking ahead, do thisthis.$refs.testElem.$el.offsetHeight
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question