Discussion
Discussion copied to clipboard
how to define global variables in vue.js?
how to I define global variables such as baseUrl, isLoggedIn, ec, then i access those from any component ?
Just put it inside data
in the main app and use inherit: true
in the child components.
Using a build tool like webpack you could define "service" modules and require
or import
those service modules into your component definition files. e.g configService
could be an object with baseUrl
, isLoggedIn
properties.
@fergaldoyle thank your goog idea.
You could create a mixin component that has a function that outputs your value.