Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

how to create a global variable in vue

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

////in components 
 console.log(this.$appName)
Comment

vue 3 global variable

// on vue 3

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

// on vue 2
Vue.prototype.$myGlobalVariable = globalVariable
Comment

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')
Comment

PREVIOUS NEXT
Code Example
Javascript :: pyspark json multiline 
Javascript :: add array of object to state react 
Javascript :: Properly upgrade node using nvm 
Javascript :: js throw custom error 
Javascript :: javascript strip 
Javascript :: jquery closert 
Javascript :: regex is empty string javascript 
Javascript :: Jquery handle change event of file upload created dynamically 
Javascript :: part of sting js 
Javascript :: django jquery 
Javascript :: Disable Initial Sorting in Datatable 
Javascript :: javascript text word wrap replace 
Javascript :: js weakset 
Javascript :: json.stringify formatting 
Javascript :: javascript get now date yyyy-mm-dd 
Javascript :: get index of item array 
Javascript :: get name of day javascript 
Javascript :: sort object by key value javascript 
Javascript :: indexOf by object key 
Javascript :: react native responsive font 
Javascript :: how to set background colour i js inline stylel 
Javascript :: toggle class javascript stack overflow 
Javascript :: javascript spread and rest operator 
Javascript :: check if string contains at least one number javascript 
Javascript :: string contains string javascript 
Javascript :: datatable on page change 
Javascript :: How do I redirect to another webpage 
Javascript :: createrouter vue 3 history remove Hash 
Javascript :: format a date moment 
Javascript :: how to add oAuth google signin in react native app 
ADD CONTENT
Topic
Content
Source link
Name
3+1 =