There is such a scene that I encountered while writing today
I wrote a router-to in the component to jump to a component and passed a name to that component. This name is in the route. Define and pass it to the jump component using the beforeEnter method
The jump component uses prop to get the name
Then I have a problem: I get the name, and now I judge the data of the name
Then methods in the component Define a method goodorbad
if (name === 'zhangsan') { return 'good' } else { return 'bad' }
Then I want to write this method into mutation in vuex now,
I will write one
export const goodorbad (state, items) { if (items.name === 'zhangsan') { return 'good' } else { return 'bad' } }
Then I write
in the jump to component...mapmutaion([ 'goodorbad' ]) ps () { let items = { name: this.name } this.goodorbad(items) }
The return cannot be obtained in this way, I think why.
Go and take a good look at the official documentation of vuex