T
T
thehighhomie2020-02-11 22:46:01
Vue.js
thehighhomie, 2020-02-11 22:46:01

I can't figure out how to set a variable like in vuex, vue-router?

hello!) why doesn't setting the global vue variable work for me?

on the example of vuex, when initializing vue, I put the variable myVariable in the option

const myVariable = { //... }
new Vue({
  myVariable,
  store,
  render: h => h(App)
}).$mount('#app')


and in components this.myVariableand this.$myVariableare equal , of undefined

course, I understand that it’s not so simple, I went to parse the code, they just export the class, I also passed the class and nothing, I can’t figure out how

much more, why then vuex also uses Vue.useto install the plugin, if in the plugin, as I understand it, you can also set a global variable.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alex, 2020-02-11
@thehighhomie

This is not how it works
https://ru.vuejs.org/v2/guide/plugins.html#%D0%A1%...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question