Static GitHub Issues

[2336] Trying to add a mixin to main Vue instance

prev: SSR CSS - document size becomes too large
next: Expose localhost to external - Debug in dev mode

Hi guys,

I'm trying to add some global data (and methods) to main Vue instance. I don't want to use Vuex so I end up with creating a plugin for nuxt:

import Vue from 'vue'

Vue.mixin({
    data: {
        my_global_config: 'This'
    },
    created: function () {
        console.log('mixin hook called')
    }
    methods: {}
})

Created method works correctly but I don't have access to data using this.$root.my_global_config Any idea?

<!--cmty--><!--cmty_prevent_hook--><div align="right"><sub><em>This question is available on <a href="https://nuxtjs.cmty.io">Nuxt.js</a> community (<a href="https://nuxtjs.cmty.io/nuxt/nuxt.js/issues/c2039">#c2039</a>)</em></sub></div>