-
Notifications
You must be signed in to change notification settings - Fork 0
/
OtherComponent.vue
60 lines (56 loc) · 1.86 KB
/
OtherComponent.vue
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
<template>
<div class="container">
<div class="row justify-content-center">
<div class="col">
<div v-if="typeof data.users !== 'undefined' && typeof data.users.data !== 'undefined' && Object.keys(data.users.data).length > 0" class="card-deck">
<div v-for="(user, index) in data.users.data" :key="index" class="card">
<h3 class="text-center p-1 m-0" v-html="user.id"></h3>
</div>
</div>
<h3 v-else-if="typeof data.users !== 'undefined' && typeof data.users.data !== 'undefined' && Object.keys(data.users.data).length === 0" class="text-center">No results found</h3>
</div>
</div>
</div>
</template>
<script>
export default {
name: 'other-component',
props: [
'pagination_data'
],
watch: {
pagination_goto: {
handler: 'getUsers',
immediate: true
}
},
methods: {
getUsers(page = ''){
const t = this;
if( page !== false &&
typeof page === 'number' &&
page !== t.data.users.current_page
){
page = '?page=' + page;
axiosUsers.get('/directory/' + routeName + page)
.then(response => {
t.data = response.data;
t.$emit('update:pagination_data', t.data.users);
});
}
}
},
mounted() {
this.getUsers();
},
data() {
return {
data: {
users: {
current_page: 1
}
}
};
}
}
</script>