diff options
| author | Paul Oliver <contact@pauloliver.dev> | 2026-03-21 01:36:24 +0100 |
|---|---|---|
| committer | Paul Oliver <contact@pauloliver.dev> | 2026-04-06 21:10:08 +0200 |
| commit | 902c660a10e654ebc96e40cfab7d09d36b7a77ac (patch) | |
| tree | c1319ce83b8fec7a6e8df37d160bc1ae1b981c95 /data/js/vue-app.js | |
| parent | 9f7e70904e6c0fa650323ac5e50ebf6003da333c (diff) | |
Adds data server
Diffstat (limited to 'data/js/vue-app.js')
| -rw-r--r-- | data/js/vue-app.js | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/data/js/vue-app.js b/data/js/vue-app.js new file mode 100644 index 0000000..80a813f --- /dev/null +++ b/data/js/vue-app.js @@ -0,0 +1,24 @@ +const { createApp } = Vue +const { loadModule } = window['vue3-sfc-loader'] + +const addStyle = styleStr => { + const style = document.createElement('style') + const ref = document.head.getElementsByTagName('style')[0] || null + style.textContent = styleStr + document.head.insertBefore(style, ref) +} + +const getFile = url => fetch(url).then(resp => resp.ok ? resp.text() : Promise.reject(resp)) +const moduleCache = { vue: Vue } + +const options = { addStyle, getFile, moduleCache } + +const app = createApp({ + components: { + App: Vue.defineAsyncComponent(() => loadModule('vue/App.vue', options)), + Section: Vue.defineAsyncComponent(() => loadModule('vue/Section.vue', options)), + Plot: Vue.defineAsyncComponent(() => loadModule('vue/Plot.vue', options)), + }, +}) + +app.mount('#app') |
