Vue dynamically binds the click method according to the index

<tr v-for="date in tableShowData">
  <td v-for="(key,i) in date" >{{ key }}</td>
</tr>

how to ignore binding

when binding a click method and other indexes according to the subscript iComple1.

Mar.05,2021

Under the

statement, this can be used, and it has been used this way all the time. I don't know why someone can't use it!

<td v-for="(key,i) in date"
  @click="i === 1 && func()">
  {{ key }}
</td>

to modify the answer upstairs, you need to set a function.

<td v-for="(key,i) in date"
  @click="() => i === 1 && func()">
  {{ key }}
</td>

in fact, all of them can be bound with click events. In particular, the click event distinguishes the situation of iSuppli events

.
<tr v-for="date in tableShowData">
    <td v-for="(key,i) in date" @click="clickHandler(i)">{{ key }}</td>
</tr>
...
clickHandler(i) {
    if (i !== 1) {
        return
    }
    // doSomething
}

you can do this

<td v-for="(key,i) in date" @click="i===1?func():''">{{ key }}</td>

Thank you God can use this method

Menu