yasTest.vue
1.9 KB
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
<!--
* @description:
* @fileName: yasTest.vue
* @author: huzhiming
* @date: 2019-11-28 10:09:21
* @后台人员:
* @version: v1.0.0
* @path: 页面访问路径及参数说明
!-->
<template>
<div class="yasTest-wrap">
<div class="top">height:1000px</div>
<div :id="`box${item.id}`" class="box" v-for="(item, index) in yasList" :key="index">
<pre>
height:100px
id: {{item.id}}
</pre>
</div>
<div class="down">height:1000px</div>
</div>
</template>
<script>
// horizontal vertical
// initHorizontalExposure
import { debounce, throttle } from 'lodash';
const mixins = {
data() {
return {
yasList: [...Array(5).keys()].map((item,index)=>({id: index, offset:null}))
}
},
created() {},
mounted() {
console.log('init mixins');
window.addEventListener('scroll', debounce(this.handleScroll,500));
// window.addEventListener('scroll', throttle(this.handleScroll,500));
},
activated() {},
deactivated() {},
// beforeRouteEnter (to, from, next) {},
// beforeRouteUpdate(to, from, next) {},
// beforeRouteLeave(to, from, next) {},
destroyed() {},
methods: {
handleScroll(e) {
console.log(e);
}
},
computed: {},
watch: {},
components: {}
}
export default {
name: 'yasTest',
mixins: [mixins],
props: {},
data() {
return {}
},
created() {},
mounted() {},
activated() {},
deactivated() {},
// beforeRouteEnter (to, from, next) {},
// beforeRouteUpdate(to, from, next) {},
// beforeRouteLeave(to, from, next) {},
destroyed() {},
methods: {},
computed: {},
watch: {},
components: {}
};
</script>
<style rel='stylesheet/scss' lang='scss' scoped>
.yasTest-wrap {
background: #f5f5f5;
.box {
width: 100vw;
height: 200px;
&:nth-child(2n) {
background: red;
}
&:nth-child(2n+1) {
background: green;
}
}
.top,.down {
height: 2000px;
}
}
//@import "./style.scss";
</style>