-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
69 lines (69 loc) · 3 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<!DOCTYPE html>
<html lang="en">
<head>
<title></title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://cdn.bootcss.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" rel="stylesheet">
<script src="https://cdn.bootcss.com/vue/1.0.7/vue.min.js"></script>
</head>
<body>
<div class="container">
<div class="col-md-12 ">
<div id="app">
<table class="table table-hover" v-cloak>
<thead>
<tr>
<th class="text-right" @click="sortBy('id')">序号</th>
<th class="text-right" @click="sortBy('name')">商品名</th>
<th class="text-right" @click="sortBy('classify')">分类</th>
<th class="text-right" @click="sortBy('price')">价格(元)</th>
<th class="text-right" >操作</th>
</tr>
</thead>
<tbody>
<tr v-for="thing in things">
<td class="text-right">{{thing.id}}</td>
<td class="text-right">{{thing.name}}</td>
<td class="text-right">{{thing.classify}}</td>
<td class="text-right">{{thing.price}}</td>
<template v-if="thing.id%2==0">
<td class="text-right">
<button type="button" class="btn btn-success" @click="delthing(thing)">删除</button>
</td>
</template>
<template v-else>
<td class="text-right">
<button type="button" class="btn btn-danger" @click="delthing(thing)">删除</button>
</td>
</template>
</tr>
<tr>
<td class="text-right" colspan="5">
<h4>总价:{{sum}}元</h4>
</td>
</tr>
</tbody>
</table>
<div id="add-thing">
<legend>添加商品</legend>
<div class="form-group">
<label>商品名</label>
<input type="text" class='form-control' v-model="thing.name">
</div>
<div class="form-group">
<label>分类</label>
<input type="text" class='form-control' v-model="thing.classify">
</div>
<div class="form-group">
<label>价格</label>
<input type="text" class='form-control' v-model="thing.price">
</div>
<button class="btn btn-primary btn-block" @click="addthing()">添加</button>
</div>
</div>
</div>
</div>
<script src="app.js"></script>
</body>
</html>