Vant Tab tab event custom parameters

< van-tabs VMI model = "active" animated @ click= "onClick" >

        <van-tab v-for="(item,index) in dome" :title="item.test" :key="index"  ></van-tab>

< / van-tabs >

The tabs event parameter in

vant is a fixed index

here is what I want

< van-tabs VMI model = "active" animated >

        <van-tab v-for="(item,index) in dome" @click="onClick(item.id)" :title="item.test" :key="index"  ></van-tab>

< / van-tabs >
dome: [

    {
      id:1,
      test:"a",
    },
     {
      id:2,
      test:"b",
    },
     {
      id:3,
      test:"c",
    },
     {
      id:4,
      test:"d",
    },
 ]




 
 
 
May.05,2022

use the title of the title slot custom tab, and then the click event is placed on the custom title. The item passed in contains all the information you want

<van-tabs v-model="active">
  <van-tab v-for="(item,index) in tabs">
    <div class="tab-title" slot="title" @click="onClick(item)">{{ item.title }}</div>
    <div class="tab-content">{{ item.content }}</div>
  </van-tab>
</van-tabs>
tabs: [
    {
    id: '1',
    title: '',
    content: ''
  },
  {
    id: '2',
    title: '',
    content: ''
  }
]
Menu