You have to believe in yourself. That's the secret of success.
You have to believe in yourself. That's the secret of success.
利用createNamespacedHelpers函数快速获取vuex模块的状态。
export default new Vuex.Store({
state,
mutations,
actions,
modules: {
user
}
})
const state = {
userName: 'ReSword'
}
const mutations = {
//
}
const actions = {
//
}
export default {
namespaced: true,
state,
mutations,
actions
}
import { createNamespacedHelpers } from 'vuex'
computed: {
const { mapState } = createNamespacedHelpers('user')
...mapState({
userName: state => state.userName
})
}
或者
import { mapState } from 'vuex'
computed: {
...mapState('user', {
userName: state => state.userName
})
}
评论没有加载,检查你的局域网
Cannot load comments. Check you network.