Load config.json at runtime
This commit is contained in:
parent
01c0eb503f
commit
589c52f4cd
11 changed files with 71 additions and 39 deletions
18
src/services/config.service.js
Normal file
18
src/services/config.service.js
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
export default {
|
||||
install(Vue) {
|
||||
var config = Vue.observable(require('@/assets/config.json'));
|
||||
const getRuntimeConfig = async () => {
|
||||
const runtimeConfig = await fetch('./config.json');
|
||||
return await runtimeConfig.json()
|
||||
}
|
||||
|
||||
config.promise = getRuntimeConfig();
|
||||
config.promise.then(function (json) {
|
||||
// Reactively use all the config values
|
||||
for (const key of Object.keys(json)) {
|
||||
Vue.set(config, key, json[key]);
|
||||
}
|
||||
});
|
||||
Vue.prototype.$config = config;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue