Skip to content

Commit 1a6198d

Browse files
committed
Reset the example file
1 parent 55ff1ae commit 1a6198d

File tree

1 file changed

+24
-54
lines changed

1 file changed

+24
-54
lines changed

example/index.html

Lines changed: 24 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<head>
44
<meta charset="UTF-8">
55
<title>vue-infinite-loading</title>
6-
<script src="https://unpkg.com/vue@2.1.9"></script>
6+
<script src="../node_modules/vue/dist/vue.min.js"></script>
77
<script src="../dist/vue-infinite-loading.js"></script>
88
<style>
99
body{
@@ -26,64 +26,34 @@
2626
</head>
2727
<body>
2828
<div id="app">
29-
<p>
30-
<button @click="component = 'foo'">Go to Foo</button>
31-
<button @click="component = 'bar'">Go to Bar</button>
32-
</p>
33-
34-
<keep-alive>
35-
<component :is="component"></component>
36-
</keep-alive>
29+
<p class="example-list-item" v-for="item in list" v-text="item"></p>
30+
<infinite-loading :on-infinite="onInfinite" :distance="distance" ref="infiniteLoading"></infinite-loading>
3731
</div>
38-
39-
<script type="text/x-template" id="bar">
40-
<div>
41-
<p v-for="item in list">
42-
Line:
43-
<span v-text="item"></span>
44-
</p>
45-
<infinite-loading :on-infinite="onInfinite" ref="infiniteLoading"></infinite-loading>
46-
</div>
47-
</script>
4832
<script>
49-
const Foo = {
50-
template: '<div>foo</div>'
51-
}
33+
new Vue({
34+
el: '#app',
35+
data: {
36+
distance: 100,
37+
list: []
38+
},
39+
methods: {
40+
onInfinite: function () {
41+
if (this.list.length > 200) {
42+
this.$refs.infiniteLoading.$emit('$InfiniteLoading:complete');
43+
} else {
44+
setTimeout(function () {
45+
var temp = [];
46+
for (var i = this.list.length; i <= this.list.length + 10; i++) {
47+
temp.push(i);
48+
}
5249

53-
const Bar = {
54-
template: '#bar',
55-
data() {
56-
return {
57-
list: [],
58-
};
59-
},
60-
methods: {
61-
onInfinite() {
62-
console.log('Running onInfinite.')
63-
setTimeout(() => {
64-
const temp = [];
65-
for (let i = this.list.length + 1; i <= this.list.length + 20; i++) {
66-
temp.push(i);
50+
this.list = this.list.concat(temp);
51+
this.$refs.infiniteLoading.$emit('$InfiniteLoading:loaded');
52+
}.bind(this), 1000);
53+
}
6754
}
68-
this.list = this.list.concat(temp);
69-
this.$refs.infiniteLoading.$emit('$InfiniteLoading:loaded');
70-
}, 1000);
71-
},
72-
},
73-
}
74-
75-
const app = new Vue({
76-
data() {
77-
return {
78-
component: null,
7955
}
80-
},
81-
components: {
82-
'foo': Foo,
83-
'bar': Bar
84-
}
85-
}).$mount('#app')
86-
56+
});
8757
</script>
8858
</body>
8959
</html>

0 commit comments

Comments
 (0)