Answers for "define global variable in vuejs"

4

how to create a global variable in vue

// in main =.js
Vue.prototype.$appName = 'My App'

////in components 
 console.log(this.$appName)
Posted by: Guest on April-18-2020
0

vue 3 global variable

// on vue 3

const app = Vue.createApp({})
app.config.globalProperties.$myGlobalVariable = globalVariable

// on vue 2
Vue.prototype.$myGlobalVariable = globalVariable
Posted by: Guest on November-17-2021
0

global variable vuejs

import Axios from 'axios'

// set global axios like this
Vue.prototype.$axios = Axios;

// call axios like this
this.$axios.get('https://jsonplaceholder.typicode.com/todos/1')
Posted by: Guest on July-07-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language