[Vuejs]-Set dynamically variables accessible with this. from an external file in VueJS not working

0👍

You don’t have to do this:

 Vue.prototype.$maintenanceMode = globalSettings.maintenanceMode
 Vue.prototype.$enableRegister = globalSettings.enableRegister

Just import those constants from settings.js file wherever you need them:

import * as settings from './settings'

EDIT >>>
You can always assign variables to ‘window’ object, in order to reach them globally:
https://stackoverflow.com/questions/11148997/window-variablename#:~:text=When%20a%20global%20variable%20is,can%20direct%20set%20window%20variable.&text=so%20when%20you%20declare%20a,value%20as%20a%20property%20value.

but the way I suggested at first is widely accepted way of handling global constants in JavaScript

Leave a comment