It seems dumb, but I have the setup as follows:
in config/index.js:
module.exports = {
API_LOCATION: 'http://localhost:8080/api/'
}
then src/app.jsI have:
import Vue from 'vue'
import VueRouter from 'vue-router'
import VueResource from 'vue-resource';
Vue.use(VueRouter);
Vue.use(VueResource);
const App = require("./app.vue");
const home = require("./components/home.vue");
const config = require('../config');
window.config = config;
Then in src/components/home.vueI have a script block that uses it like this:
<script>
module.exports = {
data: function() {
return {
obj: null
}
},
created: function() {
this.$http.get(config.API_LOCAITON + '/call').then(res => {
}, res => {
});
}
}
</script>
This works, but it seems like a bad idea to use windowto process the application configuration. What is the more canonical approach here?
Wells source
share