-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
138 lines (128 loc) · 3.89 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<script src="https://cdn.bootcss.com/vue/2.5.16/vue.js"></script>
<title>Document</title>
<style>
#app {
width: 600px;
margin: 10px auto;
}
.tb {
border-collapse: collapse;
width: 100%;
}
.tb th {
background-color: #0094ff;
color: white;
}
.tb td,
.tb th {
padding: 5px;
border: 1px solid black;
text-align: center;
}
.add {
padding: 5px;
border: 1px solid black;
margin-bottom: 10px;
}
</style>
</head>
<body>
<div id="app">
<brand-manager></brand-manager>
</div>
</body>
</html>
<script type="text/html" id="templateId">
<!-- 组件模板应该有根目录的存在 -->
<div>
<!-- //组件模板 -->
<div class="add">
编号:
<input type="text" v-model="id">
品牌名称:
<input type="text" @keyup.enter="add" v-model="name">
<input type="button" @click="add"value="添加" >
</div>
<div class="add">
品牌名称:
<input type="text" placeholder="请输入搜索条件">
</div>
<table class="tb">
<tr>
<th>编号</th>
<th>品牌名称</th>
<th>创立时间</th>
<th>操作</th>
</tr>
<!---->
<tr v-if="brandlist.length === 0">
<!--没有内容的时候显示没有数据-->
<td colspan="4">没有数据!</td>
</tr>
<tr v-for="(item,index) in brandlist" :key="item.id">
<td>{{ item.id }}</td>
<td>{{ item.name }}</td>
<td>{{ item.time | formateDate}}</td>
<td><a href="javascript:void(0)" @click = "delList(index)" >删除</a></td>
</tr>
</table>
</div>
</script>
<script>
//自定义注册事件;
Vue.component("brand-manager", {
template: `#templateId`,
data() {
return {
brandlist: [
{
id: 1,
name: "LV",
time: new Date()
},
{
id: 2,
name: "GUCCI",
time: new Date()
}
],
id: "",
name: ""
}
},
filters:{
formateDate(input,operatat="-"){
var date = new Date(input)
var year = date.getFullYear()
var month = date.getMonth()+1
var day = date.getDate()
var hour = date.getHours()
var minus = date.getMinutes();
var second = date.getSeconds();
return `${year}${month}${day}${hour}:${minus}:${second}`
}
},
methods:{
add(){
this.brandlist.push({
id:this.id,
name:this.name,
time:new Date()
})
},
delList(index){
//删除对应的列表值;
this.brandlist.splice(index,1)
}
}
});
var app = new Vue({
el: "#app",
});
</script>