javascript - Laravel + Vuex: Object/argument destructuring not working -


i'm building vue application using vuex, , can't following code work (edited brevity, inspired this blog post).

// file: views/board.vue  export default {     methods: {         updateprop (prop, value) {             console.log(prop, value) // outputs prop , value              this.$store.commit('board/updateprop', {                 [prop]: value             })         }     },      // ... } 

and in (named) vuex module:

// file: vuex/modules/board.js  export default {     mutations: {         updateprop (state, { prop, value }) {             console.log(prop, value) // outputs 'undefined undefined'         }     },      // ... } 

because import { } 'somewhere' works fine, i'm inclined believe object destructuring works. i'm baffeled why code doesn't.

i've created .babelrc file following, , installed respective plugins , presets, no avail.

{     "plugins": [         "transform-es2015-destructuring",         "transform-object-rest-spread"     ],     "presets": [         ["es2015", { "modules": false }]     ] } 

help appreciated.

this not answer, difficult fit comment. i'm not sure why both prop , value undefined, isn't how destructuring works (it not unpack key , value of object). current setup work if calling object has prop key , value key:

this.$store.commit('board/updateprop', { prop, value }) 

Comments

Popular posts from this blog

What is happening when Matlab is starting a "parallel pool"? -

angular - DownloadURL return null in below code -

php - Cannot override Laravel Spark authentication with own implementation -