What is the best way to create a constant, that can be accessible from entire application in VueJs?

Technology CommunityCategory: Vue.jsWhat is the best way to create a constant, that can be accessible from entire application in VueJs?
VietMX Staff asked 3 years ago

You can always define a variable outside of the Vue app scope and use it throughout the application.

//const.js
export default {
   c1: 'Constant 1',
   c2: 'Constant 2'
}

And:

// component.vue
import const from './const';

export default {
  methods: {
    method() {
      return const.c1;
    }
  }
}