forked from PeachScript/vue-infinite-loading
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdev_template.js
61 lines (60 loc) · 1.48 KB
/
dev_template.js
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
module.exports = `
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, maximum-scale=1, minimum-scale=1, initial-scale=1, user-scalable=no, shrink-to-fit=no">
<title>Vue-infinite-loading Testing</title>
<script src="../node_modules/vue/dist/vue.js"></script>
<script src="../vue-infinite-loading.js"></script>
<style>
body{
margin: 0;
}
.item{
margin: 0;
padding: 0 10px;
font-size: 14px;
line-height: 40px;
color: #666;
background-color: #fafafa;
border-top: 1px solid #fff;
border-bottom: 1px solid #e3e3e3;
}
.item::before{
content: 'Line: ';
}
</style>
</head>
<body>
<div id="app">
<p class="item" v-for="item in list" :key="item" v-text="item"></p>
<infinite-loading @infinite="infiniteHandler"></infinite-loading>
</div>
<script>
new Vue({
el: '#app',
data: {
list: []
},
methods: {
infiniteHandler: function ($state) {
if (this.list.length > 100) {
$state.complete();
} else {
setTimeout(function () {
var temp = [];
for (var i = this.list.length; i <= this.list.length + 10; i++) {
temp.push(i);
}
this.list = this.list.concat(temp);
$state.loaded();
}.bind(this), 1000);
}
}
}
});
</script>
</body>
</html>
`;