Creating .filter and .length function inside setup() #9072
-
Hello Quasar Friends! I am trying to create list number in my to do list by using .filter and .length function, but, I can't access it through setup() API.. I tried using this code
here is the setup ()
However, when I use this code (without access to function), it is working fine.
Please, I need help to convert the code above become a setup function, so that I can express it like the first code above Thank You Guys for helping :) Here is the complete code
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
@fakhruddinmasse Convert those functions to computed and you are missing If using reactive: const calculate = computed(() => todosOthers.filter(item => item.value.done === false).length)
const calculate2 = computed(() => todosOthers.filter(item => {return item}).length) Using ref (as in the code): const calculate = computed(() => todosOthers.value.filter(item => item.value.done === false).length)
const calculate2 = computed(() => todosOthers.value.filter(item => {return item}).length) |
Beta Was this translation helpful? Give feedback.
@fakhruddinmasse Convert those functions to computed and you are missing
.value
because it referencing a ref. I would have madetodosOthers
reactive instead of a ref.If using reactive:
Using ref (as in the code):