Apply global variable to Vuejs

The Solution to Apply global variable to Vuejs is


Just Adding Instance Properties

For example, all components can access a global appName, you just write one line code:

Vue.prototype.$appName = 'My App'

$ isn't magic, it's a convention Vue uses for properties that are available to all instances.

Alternatively, you can write a plugin that includes all global methods or properties.

~ Answered on 2017-06-16 02:05:37


Most Viewed Questions: