Last active
March 28, 2018 20:21
-
-
Save ronokdev/cc69b608c9e1b361f5f55e1517f1d22a to your computer and use it in GitHub Desktop.
Set a Global Vue Instance
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
::: RefUrl → https://vuejs.org/v2/cookbook/adding-instance-properties.html#Base-Example | |
::: Set Global instance in index.js (src/router) | |
→ Vue.prototype.$VariableName = Value; | |
→ Example : Vue.prototype.$_serverName = window.location.hostname; | |
→ $ is a convention Vue uses for properties that are available to all instances. | |
::: Access it from any Vue Components | |
→ export default { | |
created:function () { | |
console.log(this.$_serverName); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment