Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
597 views
in Technique[技术] by (71.8m points)

javascript - vuex actions - unable to dispatch payload to a consequetive actions from one another

I am trying to call one action from another within the same action.js file. I've linked those up and have achieved this, but the problem is that the first action has to pass a payload to the second.

However, when I do pass the payload:

          store.dispatch('live-chat-queue/test', {
            input: 'test input'
        })

Instead of having access to it in the second action:

    test(payload) {
    console.log('This does not work..', payload)
},

What ends up happening is I get the store returned, instead of the payload:

Console log

I have looked through ought the documentation and could not find the answer why this is returning the store, instead of the payload itself.

Thank you in advance for your help!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

As the documentation states, actions receive store object as first argument and payload as second:

test(context, payload) {
  console.log(payload) // works like expected
}


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...