fix:fixed sticky component bug in keep-alive

This commit is contained in:
Pan 2017-11-29 15:57:47 +08:00
parent 443c7aed3c
commit cef1f11931
1 changed files with 10 additions and 8 deletions

View File

@ -33,9 +33,18 @@ export default {
height: undefined,
child: null,
stickyHeight: 0
}
},
mounted() {
this.height = this.$el.getBoundingClientRect().height
window.addEventListener('scroll', this.handleScroll)
},
activated() {
this.handleScroll()
},
destroyed() {
window.removeEventListener('scroll', this.handleScroll)
},
methods: {
sticky() {
if (this.active) {
@ -62,13 +71,6 @@ export default {
}
this.reset()
}
},
mounted() {
this.height = this.$el.getBoundingClientRect().height
window.addEventListener('scroll', this.handleScroll)
},
destroyed() {
window.removeEventListener('scroll', this.handleScroll)
}
}
</script>