<script> import FormEdit from './FormEdit.vue'; import FormCreate from…
- Usercode
<el-table :data="tableData" style="width: 80%"> <el-table-column prop="nationality" label="Nationality" width="300" sortable /> <el-table-column prop="name" label="Name" width="140" sortable /> <el-table-column prop="goldMedal" label="Gold Medal" width="160" sortable /> <el-table-column prop="silverMedal" label="Silver Medal" width="160" sortable /> <el-table-column prop="bronzeMedal" label="Bronze Medal" width="160" sortable /> <el-table-column prop="totalMedals" label="Total Medals" width="160" sortable /> <el-table-column label="Operations"> <template #default="scope"> <el-button type="primary" size="mini" plain @click="handleEdit(scope.$index, scope.row)">Edit</el-button> <el-button type="danger" size="mini" plain @click="handleDelete(scope.$index, scope.row)">Delete</el-button> </template> </el-table-column> </el-table> <el-button @click="handleCreate">Add new medals</el-button> <form-edit ref="formEdit" @cancel="handleFormEditCancel" @confirm="handleFormEditConfirm"> </form-edit> <!-- @cancel is ignored --> <form-create ref="formCreate" @confirm="handleFormCreateConfirm"> </form-create>can you make it when create thing it will loadData()?
- Assistant
Certainly! You want to trigger the
loadData()method to refresh the table's data after a new item is created. You can accomplish this by callingloadData()at the end of thehandleFormCreateConfirmmethod, right after the new item is successfully added to the backend. Here's how you can modify the method:javascript