admin管理员组文章数量:1387310
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>
本文标签:
版权声明:本文标题:laravel - Vuetify+Vuex Store - "$store" was accessed during render but is not defined on instance - Stack Over 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744566501a2613079.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论