I have created a custom Vue js plugin to store global variables like so:
Constants.js file:
import Vue from 'vue'
export default {
install(Vue){
Vue.Constants = {
VERSION: '1.0.1'
}
}
}
Here is my main.js file:
import Vue from 'vue';
import App from './App';
import Constants from './plugins/Constants'
Vue.use(Constants);
new Vue({
render: h => h(App)
}).$mount('#app')
But when I tried accessing this constant in my App.vue it says undefined:
{{ Vue.Constants.VERSION }} // Not working
{{ Constants.VERSION }} // Not working
I even tried importing Vue in App.vue like so:
<script>
import Vue from 'vue'
// Rest of the code
<script>
Please suggest, There are article on how to create and install custom plugin but I couldn't find how to access it in Vue components.