Try to add store

This commit is contained in:
Jan Bader 2022-01-19 20:53:19 +00:00
parent e0f822dbcc
commit 6899e4c88e
2 changed files with 26 additions and 6 deletions

View File

@ -1,6 +1,26 @@
import { createApp } from 'vue'
import { createStore } from 'vuex'
import App from './App.vue'
import router from './router/index.js'
const store = createStore({
state () {
return {
Budgets: [],
CurrentBudget: null,
}
},
mutations: {
getDashboard (state) {
fetch("/dashboard")
.then(x => x.json())
.then(x => console.log(x))
.then(x => state.Budgets = x.Budgets);
}
}
})
const app = createApp(App)
app.use(router).mount('#app')
app.use(router)
app.use(store)
app.mount('#app')

View File

@ -1,9 +1,8 @@
<script setup>
let dashboard;
fetch("/dashboard")
.then(x => x.json())
.then(x => console.log(x))
.then(x => dashboard = x);
import { computed, onMounted } from 'vue';
onMounted(function () { console.log(this.$store)});
//const dashboard = computed(() => this.$store.state);
</script>
<!--
@ -22,6 +21,7 @@ fetch("/dashboard")
{{template "base" .}}
-->
<template>
<div v-if="dashboard != nil" v-for="budget in dashboard.Budgets" class="budget-item">
<a href="budget/{{budget.ID}}">{{budget.Name}}</a>