Load config.json at runtime

This commit is contained in:
N-Pex 2021-09-25 09:29:05 +02:00
parent 01c0eb503f
commit 589c52f4cd
11 changed files with 71 additions and 39 deletions

View 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;
}
}