We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
2.4.0
https://jsfiddle.net/50wL7mdz/63141/
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) }
} })
When state store container is Set,computed prop is working
When state store container is Set,computed prop is not working
The text was updated successfully, but these errors were encountered:
This isn't Vuex issue. Vue's reactivity system just doesn't work (currently) with Sets.
Sorry, something went wrong.
As @sqal described, this is actually Vue's issue. And this was reported several times (See vuejs/vue#1319, vuejs/vue#2410)
Thanks!
No branches or pull requests
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
The text was updated successfully, but these errors were encountered: