State
//main.js Import view from 'View' import App from './App.vue' import Vuex from 'vuex' Vue.use( Vuex ) const store = new Vuex.Store({ state:{ products: [ {Name: 'mouse', price: 20}, {Name: 'keyboard', price: 40}, {Name: 'headset', price: 60}, {Name: 'display', price: 80} ] } }) new view ({ the '#app' store, render: h => h(App) })
ProductListOne.vue
export default { data () { return { products:. this $ store.state.products // get the data in the state's store } } }
ProductListTwo.vue
export default { data () { return { products:. this $ store.state.products // get the data in the state's store } } }