data(){
	height: document.body.clientHeight - 67,
	timer: false
}

mounted() {
		const that = this
			window.onresize = () => {
				return (() => {
					window.screenHeight = document.body.clientHeight
					that.height = window.screenHeight - 67;
				})()
			}
		},
		watch: {
			height(val) {
				// 为了避免频繁触发resize函数导致页面卡顿,使用定时器
				if (!this.timer) {
					// 一旦监听到的screenWidth值改变,就将其重新赋给data里的screenWidth
					this.screenHeight = val
					this.timer = true
					let that = this
					setTimeout(function() {
						that.timer = false
					}, 400)
				}
			}
		},
Logo

前往低代码交流专区

更多推荐