【问题标题】:Get row index for Antdv table获取 Antdv 表的行索引
【发布时间】:2020-09-06 17:28:07
【问题描述】:

我需要做的就是在单击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>

【问题讨论】:

  • 这缺少很多细节
  • 没有显示您尝试如何使用getRowIndex

标签: javascript vue.js antd


【解决方案1】:

你可以在范围内传递记录,并在点击函数中引用它

    <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
    },
}

【讨论】:

    猜你喜欢
    • 2018-06-08
    • 2019-12-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-01-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多