Skip to content

Creating .filter and .length function inside setup() #9072

Discussion options

You must be logged in to vote

@fakhruddinmasse Convert those functions to computed and you are missing .value because it referencing a ref. I would have made todosOthers reactive instead of a ref.

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)

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@sfakhrym
Comment options

@metalsadman
Comment options

@sfakhrym
Comment options

@sfakhrym
Comment options

Answer selected by sfakhrym
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants