B
B
Bogdan2018-02-12 23:06:28
Vue.js
Bogdan, 2018-02-12 23:06:28

How to subscribe via this.$refs.element to addEventListener()?

Hello. How to do it right, otherwise it gives an error?

created() {
    this.$refs.textArea.addEventListener('scroll', ()=> console.log('dfdf'));
  },

TypeError: Cannot read property 'addEventListener' of undefined

Thank you.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2018-02-12
@bogdan_uman

Use mounted instead of created:

mounted() {
  this.$refs.textArea.addEventListener(...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question