0👍
The error message you are getting is because a computed by default is a getter.
In the setup() with a standalone computed they show the following example:
Example
const count = ref(1)
const plusOne = computed({
get: () => count.value + 1,
set: (val) => {
count.value = val - 1
},
})
plusOne.value = 1
console.log(count.value) // 0
- So, where do you define the ref()?
- You can get the value of the ref with .value
Computed getters/setters like this in the Options API:
let filter = computed({
get() {
console.log('get');
return createFilter(route.params);
},
set(newValue: any) {
console.log('set');
route.params = newValue;
},
});
- [Vuejs]-Wrapping dynamically added child elements in my slot
- [Vuejs]-Keep getting 'TypeError: Cannot call a class as a function' using Ziggy for Vue in Laravel
Source:stackexchange.com