简体   繁体   English

获取 Antdv 表的行索引

[英]Get row index for Antdv table

All I need to do is to get and pass the row index once I click on a button place in a cell of the a-table , I cannot find the solution for it:我需要做的就是在单击a-table单元格中的按钮位置后获取并传递行索引,但我找不到解决方案:

      <a-table
        :columns="columns"
        :data-source="getRowsData"
        :pagination="false"
        row-key="id"
      >
        <template slot="action" slot-scope="text">
          <a-button type="primary" @click="getRowIndex">
            {{ text }}
          </a-button>
        </template>
      </a-table>

you can pass the record in the scope, and refer it in click function您可以通过 scope 中的记录,并在单击 function 中引用它

    <template slot="action" slot-scope="text, record">
      <a-button type="primary" @click="() => getRowIndex(record.key)">
        {{ text }}
      </a-button>
    </template>

methods: {
   getRowIndex(key) {
      //do smthg with the key
    },
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM