M
M
Maxim2021-11-27 19:46:58
Vue.js
Maxim, 2021-11-27 19:46:58

How to add a class to each array element one by one in vue js 3 using $refs?

I have a block div

.task(v-for='(task, index) in tasks' :key='task.index' :ref="`task${index}`")
          .name
            | {{task.name}}
          .description
            | {{task.description1}}
          .time
            | {{task.time}}
          button(class='delete-task' @click="deleteCart(index)") -


mounted () {
    this.$refs.task0.classList.add('increase')
    this.$refs.task1.classList.add('increase')
  }

How to add a class to each array element one by one in vue js 3 and how to fix (Object is of type 'unknown')

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Red_Devi1, 2021-12-02
@Red_Devi1

You can do everything, the only question is why ... What prevents you from doing so?

v-for='(task, index) in tasks' :key='task.index'  class="increase"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question