[Vuejs]-Using reusable components in Vue 2 in comination with vue router

0👍

tiny recomendations

‘:class’ directive instead of native code:

document.querySelector('.dialog').classList.toggle('hidden');

components:

import Modal from './modal' 

export default {
  ...
  components:
    Modal
  }
  ...
}

instead of

Vue.component('modal', require('./modal.vue'));

.. also Vuex is a good point for this case

additional:

https://github.com/vuejs/vue-devtools

https://jsfiddle.net/uLaj738k/2/

0👍

As it turns out the problem was the moment I called the querySelector method.

Assigning the .dialog element to a const in mounted() solved my problem.

Leave a comment