javascript - 如何检查所有表 Vue.js
问题描述
我想用 vue+axios 创建 web crud。但我不明白如何创建复选框检查所有使用 vue 使用数据 api,稍后删除所有,我使用此方法但数据没有出现对不起我刚刚学习 vue + axios https://pastebin.com/iJDPU0AB
<table id="" class="table table-bordered table-striped">
<thead>
<tr>
<th><input type="checkbox" v-model="selectAll"></th>
<th>Name</th>
<th>Position</th>
<th>Office</th>
<th>Age</th>
<th>Start date</th>
<th>Salary</th>
</tr>
</thead>
<tbody id="target_listing">
<tr v-for="tl in target_listing">
<td><input type="checkbox" v-model="selected" :value="user.id" number></td>
<td>{{ tl.id_target_mst_status }}</td>
<td>{{ tl.category }}</td>
<td>{{ tl.first_name }}</td>
<td>{{ tl.last_name }}</td>
<td>{{ tl.revisit }}</td>
<td>{{ tl.visit_status }}</td>
</tr>
</tbody>
</table>
我的 app.js
var myTable = new Vue({
el: '#target_listing',
data(){
return{
target_listing:null
}
selected: []
},
mounted(){
axios
.get('http://localhost/warna2/public/api/target_listing')
.then(response => (this.target_listing = response.data.data))
.catch(error => {
console.log(error)
this.errored = true
})
},
computed: {
selectAll: {
get: function () {
return this.target_listing ? this.selected.length == this.target_listing.length : false;
},
set: function (value) {
var selected = [];
if (value) {
this.target_listing.forEach(function (user) {
selected.push(user.id);
});
}
this.selected = selected;
}
}
}
})
解决方案
推荐阅读
- python-3.x - ImportError:没有名为“keras.layers.merge”的模块
- r - 合并两个 3 数据集后,名称列不会在 R 中按字母顺序排序
- sql - ORA-01476: SQL 百分比计算中的“除数等于零”
- hyperledger - 如何使用 Hyperledger Caliper 在 Hyperledger Composer 上测试我自己的业务网络
- ios - 为什么使用 NuGet 包 Plugin.AudioRecorder 在 iPhone 上播放静音?
- azure - Azure 数据工厂 UI - 作者和监视器未加载
- javascript - 写入数组时出现错误
- javascript - 道具名称被转换为对象键
- bash - 如何获取并保存所有詹金斯工作日志的txt
- c# - 为什么我的 Razor 页面上的选项卡控件在单击时不更改内容?