1 在线编辑测试工具
https://jsfiddle.net/api/post/library/pure/
编辑好代码后点击 run 即可
2.1 html部分
https://jsfiddle.net/znebqjvL/1/?utm_source=website&utm_medium=embed&utm_campaign=znebqjvL
- <divid="app">
- <buttontype="button"class=click="add">新增</button>
- <tableclass=>
- <thead>
- <tr>
- <thwidth="100px"></th><th></th><th></th>
- <th></th><th></th><th></th>
- <th></th><th></th>
- </tr>
- </thead>
- <tbody>
- <trv-for=>
- <td>
- <selectv-model="selected"class="form-control"change=>
- <optionvalue="">空</option>
- <option:value="drug"v-for=></option>
- </select>
- </td>
- <td><inputtype="text"class="form-control"placeholder="use"v-model="item.use"></td>
- <td><inputtype="text"class="form-control"placeholder="unit":value="getDrug(item.drug_id).unit"></td>
- <td><inputtype="text"class="form-control"placeholder="rate"v-model="item.rate"></td>
- <td><inputtype="text"class="form-control"placeholder="amount":value="item.amount"input=></td>
- <td><inputtype="text"class="form-control"placeholder="price":value="getDrug(item.drug_id).price"></td>
- <td><inputtype="text"class="form-control"placeholder="money":value="item.money"></td>
- <td><buttontype="button"class=click="remove(itemIndex)">删除</button></td>
- </tr>
- <trv-if="!items.length">
- <tdcolspan="8"class="empty">尚未新增任何资料</td>
- </tr>
- <tr>
- <tdcolspan="8"class="right"></td>
- </tr>
- </tbody>
- </table>
- <hr>
- <p>
- <pre>
- </pre>
- </p>
- </div>
- d>d.id
- drugthis
- money
- item.moneyisNaN
- this.totalMoneyparseFloati>>
- item.drug_idparseInt
- amountparseFloat
- item.amount
- item.amountamount
- item.amount0
2.3 css部分