Try to add store
This commit is contained in:
parent
e0f822dbcc
commit
6899e4c88e
@ -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')
|
||||
|
@ -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>
|
||||
|
Loading…
x
Reference in New Issue
Block a user