【发布时间】:2023-03-20 07:17:01
【问题描述】:
这是我的桌子。如您所见,我添加了一个按钮来执行操作。该操作需要在单击时将活动更改为不活动,并且将不活动更改为活动。我似乎找不到可以访问的 SQL 区域,这使我很难在单击时更新数据库。任何建议或帮助将不胜感激。如果单击此按钮后有任何方法可以更新数据库,那么新值也应该出现在数据表中。
<table class="table" id="myTable">
<thead>
<tr>
<th>Status</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<tr v-for="product in filteredProducts" :key="product.id">
<td>{{ product.status }}</td>
<td>
<div class="btn-group" role="group">
<button class="btn btn-secondary" @click="acdcProduct(product.id)">Active/Deactive</button>
</div>
</td>
</tr>
</tbody>
</table>
这是我迄今为止尝试做的事情。对不起,我是 vue.js 的新手
acdcProduct(id) {
this.axios
.acdc(`http://localhost:8000/api/products/${id}`)
let i = this.products.map(data => data.id).indexOf(id);
this.products.status(i, active)
}
【问题讨论】:
标签: javascript laravel vue.js