[Vuejs]-Accessing DOM element in Vuejs component not reliable

0👍

OK, after trying many different things I’ve managed to solve this by using a non-reactive intermediate variable. This means that I can’t use the variable in a template but that is fine.

export default {
  ..
  // NOT reactive so you can't just use it in your templates.
  _selectableItems: [],

  updated(){
    self._selectableItems = self.$el.querySelectorAll('.selectable-item')
  },
  ..
}

Leave a comment