Am trying to create a central store to store my data and fecth it from the store but am getting an undefined error
am using "vuex": "^4.1.0" and "vue": "^2.6.12",
I have the files working but when i add the computed property i get the error
store.js
import Vue from "vue";
import Vuex from 'vuex';
Vue.use(Vuex);
export const store = new Vuex.Store({
state: {
products: [
]
}
});
Test.vue
<template lang="en">
<div>
<h2>Test list</h2>
<ul>
<li v-for="product in products">
{{product.name}}
</li>
</ul>
</div>
</template>
<script>
export default {
computed: {
products(){
return this.$store.state.products;
}
}
}
</script>
App.js
require('./bootstrap');
import Vue from 'vue';
import vuetify from './vuetify';
import {store } from './store/store.js'
require('./routes')
const app = new Vue({
store,
el: '#app',
vuetify
});
CodePudding user response:
you need to use Vuex 3, which works with Vue 2:
CodePudding user response:
Changed to vuex 3 gave it some minutes to think and now working