私はいくつかの情報を含む複数の行を持つテーブルを持っています。ユーザーは、(各行のチェックボックスを使用して)好きな行をいくつでも選択することができます。行を選択(または選択解除)するたびに、totalSelected
を更新します。Vue.jsに複数の数値のテキストボックスをバインドする
私のViewModelは現在、次のようになります。
var viewModel = new Vue({
el: "#OrderPickContainer",
data: {
ProductTitle: "",
Batches: [],
totalSelected: 0
},
methods: {
// I have some unrelated methods here
}
});
私のテーブルには、次のようになります。複数の行があるので、私がいる問題は、どのように把握され、
<table class="table table-striped">
<thead>
<tr>
<th>Select</th>
<th>Batch Number</th>
<th>Available</th>
<th>Quantity</th>
</tr>
</thead>
<tbody>
<template v-for="batch in Batches">
<tr>
<td><input type="checkbox" /></td>
<td>{{ batch.BatchNumber }}</td>
<td>{{ batch.AvailableQuantity }}</td>
// This is the input that I would like to bind to update `totalSelected`. The issue though is there are multiple rows with this exact input and I want them all to be able to add or subtract to the total.
<td><input type="number" min="0" class="form-control" /></td>
</tr>
</template>
<tr>
<td></td>
<td></td>
<td><strong>Total:</strong></td>
<td><strong>{{ totalSelected }}</strong></td>
</tr>
</tbody>
</table>
ので、それらの番号のテキストボックスのすべてを1つのVue変数にバインドします。
完全に質問をアドレスしてくれてありがとう:) – Quiver