先看下效果:
为了方便起见,使用了table布局:
<div id="app">
<table>
<tr>
<th>商品</th>
<th>数量</th>
<th>单价</th>
<th>金额</th>
</tr>
<tr v-for="item in goods" :key="item.id">
<td>
<input type="checkbox" @click="handleCheckClick(item)"/>
{
{ item.name }}
</td>
<td>
<button @click="calcSingleGoodPrice(item, 0)">-</button>
<input type="text" v-model="item.number"/>
<button @click="calcSingleGoodPrice(item, 1)">+</button>
</td>
<td>{
{ item.price }}</td>
<td>{
{item.price