Answer the question
In order to leave comments, you need to log in
How to get property from plugin in vue component?
The plugin has its own store. There is someProp property in the plugin store.
export default {
namespaced: true,
state: {
someProp: null,
},
mutations: {
set(state, value) {
state.someProp = value;
},
},
}
import myStore from './store'
export default {
install(Vue, { store }) {
store.registerModule('myStore', myStore);
Vue.prototype.$myPlugin = {
set(value) {
store.commit('myStore/set', value);
},
// как правильно возвращать someProp из стора через плагин?
someProp: store.state.myStore.someProp, // << это возвращает null и после изменения через мутацию
};
}
}
<div>{{ $myPlugin.someProp }}</div>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question