2

I have a loop component runned by a function to filter by inputs and selects. Can I get a reactive number of elements renderized by this filter?

<component-list class=""v-for="(item, index) in itemsFilters()" :key="index" :propId="item.id"
></component-list>

itemsFilter() returns a filter of an object array by selects and inputs. I have a pen with an example of this situation: https://codepen.io/joaosaro/pen/baXgjG

1 Answer 1

3

If itemsFilter is either computed or a method:

 computed: {
      itemsCount () {
          // itemsFilters is computed 
          return this.itemsFilters.length
          // or a method
          return this.itemsFilters().length
      }
  }
Sign up to request clarification or add additional context in comments.

1 Comment

Is what I need, thanks. I need to assign to a data element, so I did that inside itemsCount() and return the data variable. Then I can use on component tag as @change="itemsCount"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.