0👍
✅
Ignoring the reverse, here is way to work with store data and computed properties.
computed: {
items () {
return this.$store.state.wishlist.items
},
itemCount () {
// assuming this.$store.state.wishlist.items is array
return this.items.length
}
},
methods: {
getPosts () {
for (i = 1; i <= this.itemCount; i++) {
this.posts.push({
first: 'John',
last: 'Doe',
suffix: '#' + i
})
}
}
}
-1👍
You have to treat computed functions as a variable when you call them. A computed function can have a getter and a setter.
If you have a setter, you can trigger it using something like:
this.computedVar = 2;
If you have a getter, you can trigger it using:
this.computedVar;
As you can see, in both cases you treat it like a variable when you call it.
Source:stackexchange.com