我的mutation.js
//失败的方法
import * as types from './mutation-types'
const mutations = {
[types.SET_MUSICLIST](state, payload) {
state.musicList = payload
}
}
export default mutations
//成功的方法
// export const SET_MUSICLIST = (state, payload) => {
// state.musicList = payload
// }
//mutation-types.js
export const SET_MUSICLIST = 'SET_MUSICLIST'
//组件中
...mapMutations({
SetMusicList: 'SET_MUSICLIST'
})
为什么两种写法会一个成功一个失败呢?是我export不对吗?
你这里语法错误,函数声明不能使用变量的值