i´m trying to create an app with laravel 12 and vuetify. I´m following the steps of: .html#getting-vuex-state-into-vue-components but i cant make working.
The browser is empty and the console show (App.vue:10): Uncaught TypeError: Cannot read properties of undefined (reading 'state')
store.js:
import { createApp } from 'vue'
import { createStore } from 'vuex'
import App from '../web/App.vue';
const store = createStore({
state () {
return {
count: 0
}
},
mutations: {
increment (state) {
state.count++
}
}
})
const app = createApp(App)
app.use(store)
app.vue
<template>
<div>Counter: {{ count }}</div>
<v-btn @click="increment()">Increment</v-btn>
</template>
<script>
export default {
data () {
return {
count: this.$store.state.count
}
},
created() {
},
mounted() {
},
computed: {
},
methods: {
increment() {
this.$storemit('increment')
console.log(this.$store.state.count)
}
}
}
</script>