Friday, 1 February 2019

Make prototype accessible in vuex

In my app.js file I build this so I can use translation in vue:

Vue.prototype.trans = string => _.get(window.i18n, string);

This is working great in my vue files:



The problem is that I'm using vuex and I need to translate some things in a module:

import Vue from 'vue';
import Vuex from 'vuex';

Vue.use(Vuex);

export default {
    namespaced: true,

    state: {
        page: 1,
        criterias: [
            {
                name: this.trans('translation.name'),
                filter: "life",
                active: false
            }
     }
 }

But here this.trans('translation.name') is not working. How could I get this to work?



from Make prototype accessible in vuex

No comments:

Post a Comment