We will learn How to declare a global variable in Vue JS?

Example:

<!DOCTYPE html>
<html>
<head>
    <title>How to declare global variable in Vue JS? - rathorji.in</title>
    <script src="https://cdn.jsdelivr.net/npm/vue"></script>
</head>
<body>
    
<div id="app">
    
  <p>Result : {{myResult}}</p>
  <button @click="clickFunction()">Click Me</button>
    
</div>
   
<script type="text/javascript">
     
    Vue.mixin({
      data: function() {
        return {
          myGlobalVar:'this is my rathorji.in'
        }
      }
    })
 
    var app = new Vue({
      el: '#app',
      data: {
        myResult: ''
      },
      methods:{
        clickFunction: function () {   
            this.myResult = this.myGlobalVar;
        }
      }
    })
    
</script>
    
</body>
</html>

I hope this helped you.