Skip to content
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

When state store container is Set rather than Array,computed prop does not work! #961

Closed
VancySavoki opened this issue Sep 21, 2017 · 3 comments

Comments

@VancySavoki
Copy link

Version

2.4.0

Reproduction link

https://jsfiddle.net/50wL7mdz/63141/

Steps to reproduce

Vue.use(Vuex)
const store = new Vuex.Store({
state: {
tasks: new Set(),
tasks2: []
},
getters: {
taskCounts: state => {
return state.tasks.size
},
taskCounts2: state => {
return state.tasks2.length
}
},
mutations: {
commitTasks(state,task) {
// 变更状态
state.tasks.add(task)
},
commitTasks2(state,task) {
// 变更状态
state.tasks2.push(task)
}
}
})
new Vue({
el: '#app',
data: {
message: 'Hello Vue.js!'
},
store,
computed:{
taskCounts:function(){
return this.$store.getters.taskCounts
},
taskCounts2:function(){
return this.$store.getters.taskCounts2
}

},
methods:{
add(){
let tasks = {}
this.$store.commit("commitTasks",tasks)
},
add2(){
let tasks = {}
this.$store.commit("commitTasks2",tasks)
}

}
})

What is expected?

When state store container is Set,computed prop is working

What is actually happening?

When state store container is Set,computed prop is not working

@sqal
Copy link

sqal commented Sep 21, 2017

This isn't Vuex issue. Vue's reactivity system just doesn't work (currently) with Sets.

@ktsn
Copy link
Member

ktsn commented Sep 21, 2017

As @sqal described, this is actually Vue's issue. And this was reported several times (See vuejs/vue#1319, vuejs/vue#2410)

@ktsn ktsn closed this as completed Sep 21, 2017
@VancySavoki
Copy link
Author

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants