forked from pikax/vue-composable
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharrayPagination.html
61 lines (53 loc) · 1.29 KB
/
arrayPagination.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
<html>
<head>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script>
Vue.config.devtools = true
</script>
</head>
<body>
<div id="app">
<p>page {{currentPage}} of {{ lastPage }}</p>
<p>
<label for="pageSize">Page size</label>
<input name="pageSize" v-model="pageSize" type="number">
</p>
<p>
<button @click="prev">prev</button>
<button @click="next">next</button>
</p>
<ul>
<li v-for="n in result" :key="n">
{{ n }}
</li>
</ul>
</div>
<script src="https://cdn.jsdelivr.net/npm/@vue/[email protected]/dist/vue-composition-api.umd.js"></script>
<script>
// add composition api to vue
Vue.use(vueCompositionApi.default);
</script>
<script src="../dist/vue-composable.umd.js"></script>
<script>
const {
useArrayPagination
} = vueComposable;
new Vue({
el: "#app",
setup(){
const array = new Array(1000).fill(0).map((_, i)=> i);
const { next, prev, currentPage, lastPage, result, pageSize, offset} = useArrayPagination(array, {})
return {
next,
prev,
currentPage,
lastPage,
pageSize,
result,
offset
}
}
})
</script>
</body>
</html>