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 :: npm install could not resolve peerDependencies 
Javascript :: jquery: finding all the elements containing the text present in an array 
Javascript :: babel debugging 
Javascript :: Self Invoking Function Simpler Syntax 
Javascript :: javascript trigger function when element is in viewport 
Javascript :: vue js app component 
Javascript :: node powershell 
Javascript :: remove trailing zeros javascript 
Javascript :: black adam release date 
Javascript :: javascript map array 
Javascript :: react render twice v18 
Javascript :: javascript get cursor position without event 
Javascript :: remove substring from string liquid shopify 
Javascript :: jquery add class except this 
Javascript :: convert string to integer in javascript 
Javascript :: modern javascript for loop syntax 
Javascript :: type coercion 
Javascript :: text background fabricjs 
Javascript :: javascript remove from array 
Javascript :: npm ERR! Error: connect ECONNREFUSED 
Javascript :: template literals in javascript 
Javascript :: javascript kill all childs 
Javascript :: javascript comments 
Javascript :: moment.set 
Javascript :: javascript perform click 
Javascript :: autocomplete react jsx attributes vscode 
Javascript :: Mongoose and multiple database in single node.js project 
Javascript :: update a certain key in dictionary javascript 
Javascript :: longitud objeto javascript 
Javascript :: vs code shortcut for switching to terminal to editor 
ADD CONTENT
Topic
Content
Source link
Name
6+6 =