我将 vue js 与 vuetify 和 laravel 一起使用。我有一个带有动态数据表的组件,它使用 axios 从数据库中获取数据。该数据表中还有 v-checkboxes。所以一切都按我的预期工作。但是现在我想在 v-checkbox 中调用两个函数 onchange 事件。例如,当用户单击复选框(选中)时,我想调用保存功能,当用户取消选中复选框时,我想调用删除功能。我尝试使用 v-checkbox 的 id 来执行此操作,并检查该复选框是否已选中,然后调用保存函数,否则调用删除函数。然后,当用户选中复选框时,保存函数被调用,但当用户取消选中复选框时,两个函数都会被调用。这就是我被困的地方。我该如何存档?
数据表
<v-data-table :headers="customer_headers" :items="customers" :search="customer_search" item-key="CustomerCode" ref="customer_table">
<template slot="items" slot-scope="props">
<tr :id="'customer_tr_'+props.item.CustomerCode">
<td class="text-md-center">{{ props.item.CustomerCode }}</td>
<td class="text-md-center">{{ props.item.CustomerName }}</td>
<td class="text-md-center">{{ props.item.NO_OF_DISPENSERS }}</td>
<td class="text-md-center">{{ props.item.next_service_date }}</td>
<td class="text-md-center">{{ props.item.STATUS }}</td>
<td class="text-md-center">{{ props.item.Workerstatus }}</td>
<td class="text-md-center">
<v-checkbox
:key="props.item.CustomerCode"
:ref="'customer_checkbox_ref' + props.item.CustomerCode"
:id="'customer_checkbox_'+props.item.CustomerCode"
@change="loadCustomerDispensers(props.item.CustomerCode,props.item.STATUS);changeServicePlanData()"
></v-checkbox>
</td>
</tr>
</template>
</v-data-table>
Run Code Online (Sandbox Code Playgroud)
我正在尝试这个changeServicePlanData()功能changeServicePlanData()
function changeServicePlanData(id) {
if ($('#' + id).checked …Run Code Online (Sandbox Code Playgroud)