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 :: Checking Empty JS Object 
Javascript :: Two different lockfiles found: package-lock.json and yarn.lock 
Javascript :: jquery scrollheight 
Javascript :: nodejs date difference 
Javascript :: node get absolute path 
Javascript :: 3 = signs in javasdcript 
Javascript :: angular disabled condition based 
Javascript :: datatables add row 
Javascript :: cypress ignore error 
Javascript :: ant design table sort string perfectly 
Javascript :: res.status 
Javascript :: fetching foreign key data in sequelize 
Javascript :: this keyword in javascript medium 
Javascript :: javascript alert random word 
Javascript :: reverse a string without affecting special characters in javascript 
Javascript :: font ligature vs code 
Javascript :: fetch and edit jsonplaceholder api 
Javascript :: jquery get text of input 
Javascript :: vanilla javascript add class 
Javascript :: using index of on array of objects 
Javascript :: js string to regex 
Javascript :: ACCESS IFRAME INNER HTML IN CHROME CONSOLE 
Javascript :: javascript disable resize window 
Javascript :: find the index of an object in an array 
Javascript :: how to map objects in react native 
Javascript :: how to remove last digit from number in javascript 
Javascript :: jquery selector exists 
Javascript :: laravel jquery csrf 
Javascript :: javascript remove class with transition 
Javascript :: [Error - 10:52:45 PM] Failed to load jshint library 
ADD CONTENT
Topic
Content
Source link
Name
4+2 =