<div id="aside" class="bs-aside" :class="{'is_fixed' : isFixed}">
	<asidePreview></asidePreview>
</div>

mounted() {
	window.addEventListener('scroll', this.handleScroll);
	this.$nextTick(() => {
		this.offsetTop = document.querySelector('#aside').offsetTop;
	})
},
destroyed() {
	window.removeEventListener('scroll', this.handleScroll)
},
methods: {
	
	handleScroll() {
		var scrollTop = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop
		this.isFixed = scrollTop > this.offsetTop ? true : false;
		console.log(scrollTop)
		if(scrollTop > 1400){
			this.isFixed = false
		}
	},
	
},

By lxcss

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注