[Vuejs]-Vue store a variable on one page and call on another

1👍

You have to export the variable in config.js first, then import that variable in your Geturl.vue:

config.js

export var myUrl = "http://localhost:7070/#/";

Script for Geturl.vue

<script>

  import { myUrl } from '/config.js';

  export default {
  name: 'App',
  components: {
  },

  data(){
    return{
      loadNewUrl: myUrl,  /** how to get myUrl value from config.js file **/
    }
  }
</script>

More:

The variables in the JS file are not accessible from other files – export makes them “public”

Leave a comment