store.dispatch('urrent_user')
.then(r => {
// next processing
})
.catch(e => {
// goto login
})
{
state: {
currentLang: 'RU',
translations: {
RU: {
label1: 'some ru text',
label2: 'some ru text',
},
EN: {
label1: 'some en text',
label2: 'some en text',
}
}
},
getters: {
translate: (state) => (label) => {
return state.translations[state.currentLang][label]
}
}
}
this.$store.getters.translate('label1')
sendWithCheck(action1,action2, params) {
this.$store.dispatch(action1, params)
.then(r => {
if(r.result) {
showConfirmMessage('textmessage', () => {
// this is confirm event handler just for example
this.$store.dispatch(action2)
})
} else {
this.$store.dispatch(action2)
}
})
}
<script src="path_to_script"></script>
<script type="text/javascript">
var vm;
vm = vuecomp.init("vuecomponent", {
// some options
});
</script>
<div id="vuecomponent"></div>
import Vue from 'vue'
// ...
const vuecomp = {
init(elementId, options) {
return new Vue({
el: `#${elementId}`,
// ...
})
}
}
export default vuecomp