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:
-
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import
-
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/export
The variables in the JS file are not accessible from other files – export
makes them “public”
Source:stackexchange.com