1

After searching the products on the search button, I have to list them in the background and make a selection.

Codes:

//The area I want clicked each time
<div v-for="(item, index) in filteredProducts" @click="addToList(item)"></div>

How can I get it to take action automatically?

2 Answers2

0

What do you mean "take action?" Do you want to run addToList(item) function every time someone searches a product?

You can use a watcher or computed property and run that addToList function when filteredProducts change, instead of a click event. I don't see why you would want to "auto click" on a div.

If you could further explain your question and provide a larger codebase, I could help better.

0

You Can Use computed See This Answer

computed: {
    addToListComputed (item) {
        addToList(item)
    },
},
Ali Chraghi
  • 613
  • 6
  • 16