diff --git a/src/prog/dashboard3/README.md b/src/prog/dashboard3/README.md index f8366c6c..0e0f0bd6 100644 --- a/src/prog/dashboard3/README.md +++ b/src/prog/dashboard3/README.md @@ -31,3 +31,6 @@ export default { a suivre !!!!=> https://appdividend.com/2018/05/08/vuex-axios-get-request-tutorial-with-example/ + +example 2 +https://github.com/vuejs/vuex/blob/dev/examples/shopping-cart/components/ProductList.vue \ No newline at end of file diff --git a/src/prog/dashboard3/src/pages/sprinklers.vue b/src/prog/dashboard3/src/pages/sprinklers.vue index 5e718328..c529892e 100644 --- a/src/prog/dashboard3/src/pages/sprinklers.vue +++ b/src/prog/dashboard3/src/pages/sprinklers.vue @@ -33,13 +33,14 @@ import { mapState } from 'vuex' export default { name: 'PageSprinklers', - mounted () { - console.log('mounted') + computed: mapState({ + sprinklers: state => state.sprinklers.all + }), + created () { + console.log('created') this.$store.dispatch('sprinklers/load') - }, - computed: mapState([ - 'sprinklers' - ]) + console.log('sprin', this.sprinklers) + } } diff --git a/src/prog/dashboard3/src/store/modules/sprinklers.js b/src/prog/dashboard3/src/store/modules/sprinklers.js index fd87915c..11be7c52 100644 --- a/src/prog/dashboard3/src/store/modules/sprinklers.js +++ b/src/prog/dashboard3/src/store/modules/sprinklers.js @@ -3,7 +3,7 @@ import api from '../../api/domo' // initial state // shape: [{ id, quantity }] const state = { - sprinklers: [] + all: [] } // getters @@ -38,16 +38,6 @@ const actions = { }) } } -/* - axios - .get('http://localhost:4000/results') - .then(r => r.data) - .then(coins => { - commit('SET_COINS', coins) - }) - } - } -*/ /* checkout ({ commit, state }, products) { @@ -85,7 +75,7 @@ const actions = { const mutations = { SET_SPRINKLERS (state, sprinklers) { console.log('sprinkler', sprinklers) - state.sprinklers = sprinklers + state.all = sprinklers } /* pushProductToCart (state, { id }) {