0๐
โ
You should handle the else
case :
computed: {
features() {
if(this.$store.getters.features) {
return this.$store.getters.features
} else{
return false;
}
}
but itโs recommended to use the second syntax.
0๐
In a computed property, you should always ensure that a value is returned, no matter what condition is met.
In your computed property, you have an if
statement that checks if this.$store.getters.features
is truthy
, and if it is, it returns the value. However, if the condition is not met (if this.$store.getters.features
is falsy
), the function does not return anything, which is the cause of the error.
Example :
computed: {
features() {
if (this.$store.getters.features) {
return this.$store.getters.features;
} else {
return null; // You can use any return value here as per requirement
}
}
}
Source:stackexchange.com