-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
108 lines (103 loc) · 2.48 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
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="utf-8">
<title>Lesson 2</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>
<body>
<div id="app">
<div class="container mt-5">
<div class="row">
<div class="col"><h1>{{users.length }} users</h1></div>
<div class="col">
<button type="button" v-on:click="switcher" class="btn btn-secondary">show/hide</button>
</div>
</div>
<table class="table table-hover table-striped" :class="{'d-none': !is_visible }">
<thead>
<tr>
<th>#</th>
<th>Name</th>
<th>Surname</th>
<th>Patronymic</th>
<th>Photo</th>
<th></th>
</tr>
</thead>
<tbody>
<tr v-for="(user, key) in users" :key="user.id">
<th>{{ key + 1 }}</th>
<td>{{ user.name | uppercase }}</td>
<td>{{ user.surname }}</td>
<td>{{ user.patronymic }}</td>
<td>
<img v-if="user.image" :src="user.image" alt="">
<p v-else>показывать аватарку по умолчанию<p>
</td>
<td><button type="button" v-copy="key" class="btn btn-secondary">copy</button></td>
</tr>
</tbody>
</table>
</div>
</div>
<script>
var app = new Vue({
el: '#app',
data: function () {
return {
is_visible: true,
users: [
{
id: 1,
name: 'Name 1',
surname: 'Surname 1',
patronymic: 'Patronymic 1',
image: 'https://i.imgur.com/zSGftLct.png'
},
{
id: 2,
name: 'Name 2',
surname: 'Surname 2',
patronymic: 'Patronymic 2',
image: ''
},
{
id: 3,
name: 'Name 3',
surname: 'Surname 3',
patronymic: 'Patronymic 3',
image: 'https://i.imgur.com/zSGftLct.png'
},
{
id: 4,
name: 'Name 4',
surname: 'Surname 4',
patronymic: 'Patronymic 4',
image: 'https://i.imgur.com/zSGftLct.png'
},
{
id: 5,
name: 'Name 5',
surname: 'Surname 5',
patronymic: 'Patronymic 5',
image: 'https://i.imgur.com/zSGftLct.png'
},
]
};
},
filters: {
uppercase: function (value) {
return value.toUpperCase();
}
},
methods: {
switcher: function () {
this.is_visible = !this.is_visible;
}
}
});
</script>
</body>
</html>