我目前正在使用 Vue-datatable,我有一个通用的 vue 组件作为 . 我正在使用这个基本组件来呈现数据表,并且我在元素中有一个 @click 事件。但是当我在不同的地方使用这个组件时,我希望 @click 事件被覆盖,这样我就可以根据我的需要调用不同的方法。
下面的文件是 BaseTable.vue
<v-app id="inspire">
<v-data-table
v-model="selected"
:headers="headers"
:items="desserts"
:pagination.sync="pagination"
select-all
item-key="name"
class="elevation-1"
>
<template v-slot:headers="props">
<tr>
<th>
<v-checkbox
:input-value="props.all"
:indeterminate="props.indeterminate"
primary
hide-details
@click.stop="toggleAll"
></v-checkbox>
</th>
<th
v-for="header in props.headers"
:key="header.text"
:class="['column sortable', pagination.descending ? 'desc' : 'asc', header.value === pagination.sortBy ? 'active' : '']"
@click="changeSort(header.value)"
>
<v-icon small>arrow_upward</v-icon>
{{ header.text }}
</th>
</tr>
</template>
<template v-slot:items="props">
<tr :active="props.selected" @click="props.selected = !props.selected">
<td>
<v-checkbox
:input-value="props.selected"
primary
hide-details
></v-checkbox>
</td>
<td>{{ props.item.name }}</td>
<td class="text-xs-right">{{ props.item.calories }}</td>
<td class="text-xs-right">{{ props.item.fat }}</td>
<td class="text-xs-right">{{ props.item.carbs }}</td>
<td class="text-xs-right">{{ props.item.protein }}</td>
<td class="text-xs-right">{{ props.item.iron }}</td>
</tr>
</template>
</v-data-table>
</v-app>
</template>```
Could I possibly override the triggercall method shown above in the code?
Thanks.