New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I push value with array into ...mapAction #1435

Closed
korpong753 opened this Issue Oct 26, 2018 · 1 comment

Comments

Projects
None yet
2 participants
@korpong753

korpong753 commented Oct 26, 2018

I have a question about if I have a value with array which the data will come from check box menu when we clicked. Actually, I want to use data in array name is 'mdbListSelected' that was collected data from user selected on other component and want to know how much user selected its every time as well. I try to use Vuex like below but it doesn't work, Eventhough, I try to use ...mapAction to define in v-model of Treeselect but it doesn't work too. Anyone know how to correct it please explain me, Thank a lot.

*** I have tried to use simple vuex by get message from it via getter name getMessage and it work normally. ***

==================================================
## listcomponent.vue ##

<treeselect
:normalizer="normalizer"
:multiple="true"
:options="mdbsList"
:disable-branch-nodes="true"
:value-consists-of="BRANCH_PRIORITY"
:default-expand-level="1"
:alwaysOpen="true"
:max-height="460"
search-nested
v-model="dataSelected" // Contains data that selected
/>

^<script>
export default {
data() {
return {
mdbsList: [ ],
mdbListSelected: [ ], // The data that was collected when user selected
},
methods: {
...mapActions(['mdbSelected'])
}

=======================================================
## store.js ##
const state = {
message: 'Hello from VueX',
selected: [ ]
}
const mutations = {
MDBFILTERSELECTED(state, payload) {
state.selected = payload
console.log(selected)
}
}
const actions = {
mdbSelected(context, param) {
context.commit('MDBFILTERSELECTED', param)
}
}

const getters = {
getMessage: state => state.message,
getMDBSelected: state => state.selected
}

export default {
state,
getters,
mutations,
actions
}

@vue-issue-bot

This comment has been minimized.

vue-issue-bot commented Oct 26, 2018

Hello, your issue has been closed because it does not conform to our issue requirements. In order to ensure every issue provides the necessary information for us to investigate, we require the use of the Issue Helper when creating new issues. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment