Try to add store
This commit is contained in:
parent
e0f822dbcc
commit
6899e4c88e
@ -1,6 +1,26 @@
|
|||||||
import { createApp } from 'vue'
|
import { createApp } from 'vue'
|
||||||
|
import { createStore } from 'vuex'
|
||||||
import App from './App.vue'
|
import App from './App.vue'
|
||||||
import router from './router/index.js'
|
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)
|
const app = createApp(App)
|
||||||
app.use(router).mount('#app')
|
app.use(router)
|
||||||
|
app.use(store)
|
||||||
|
app.mount('#app')
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
let dashboard;
|
import { computed, onMounted } from 'vue';
|
||||||
fetch("/dashboard")
|
|
||||||
.then(x => x.json())
|
onMounted(function () { console.log(this.$store)});
|
||||||
.then(x => console.log(x))
|
//const dashboard = computed(() => this.$store.state);
|
||||||
.then(x => dashboard = x);
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
@ -22,6 +21,7 @@ fetch("/dashboard")
|
|||||||
{{template "base" .}}
|
{{template "base" .}}
|
||||||
-->
|
-->
|
||||||
|
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div v-if="dashboard != nil" v-for="budget in dashboard.Budgets" class="budget-item">
|
<div v-if="dashboard != nil" v-for="budget in dashboard.Budgets" class="budget-item">
|
||||||
<a href="budget/{{budget.ID}}">{{budget.Name}}</a>
|
<a href="budget/{{budget.ID}}">{{budget.Name}}</a>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user