【问题标题】:How to make rows of table clickable in VueJS?如何在 VueJS 中使表格的行可点击?
【发布时间】:2021-01-11 08:35:53
【问题描述】:
【问题讨论】:
标签:
vue.js
datatables
click
core-ui
【解决方案1】:
像这样添加事件监听器
请关注方法中的@row-clicked="rowClickHandler"和方法rowClickHandler
<template>
<CCardBody>
<CDataTable
:items="items"
:fields="fields"
@row-clicked="rowClickHandler" // <== focus here
>
... Rest of the code
</CDataTable>
</CCardBody>
</template>
<script>
export default {
name: 'AdvancedTables',
data () {
return {
items: [],
fields: [],
}
},
methods: {
rowClickHandler ((item, index, column name, event) {
// whatever you want to do
},
... other methods
}
}
</script>