Home > Software engineering >  how to use properties file in vueJs?
how to use properties file in vueJs?

Time:11-24

hi is there any way to store most usable values and properties in a file like yml - property file and ...

and use them in vueJs components

in java we have spring and it helps us using yml and property file properties in project

is there any thing same in vueJs

CodePudding user response:

In vueJs you can use .env files easily. In you .env file you can define properties starting with VUE_APP_ and them will be available for you in the whole app.

Ex: .env

    VUE_APP_API_URL=http://localhost:5000

To read this property just do it.

process.env.VUE_APP_API_URL

More info here.

CodePudding user response:

you can build an object in a .js file and import that obj as your configuration.
no file system exists in pure front-end
or you can get your configuration from a backend api

CodePudding user response:

You can create a normal JS file and import in the Vue.

Or you might need to read about .env file because between those 2 files you gonna need for constants

  • Related