页面出现滚动条
出现问题
页面在跳转城市的时候页面出现滚动条
问题原因
this.height = document.documentElement.clientHeight -
document.querySelector('.routerul').offsetHeight -
this.$refs.navbar.$el.offsetHeight + 'px'
document.querySelector('.routerul').offsetHeight在跳转回来时获取的值为0
解决方法
if (this.$store.state.istabbarheight) {
this.height = document.documentElement.clientHeight -
this.$store.state.istabbarheight-
this.$refs.navbar.$el.offsetHeight + 'px'
} else {
this.height = document.documentElement.clientHeight -
document.querySelector('.routerul').offsetHeight -
this.$refs.navbar.$el.offsetHeight + 'px'
}
this.$store.state.istabbarheight采用vuex公共状态管理和document.querySelector('.routerul').offsetHeight
两个获取选项卡高度的笨办法
在页面第一次刷新的时候,页面先渲染,前者获取值为0,走else,当去到城市组件回来时,前者已经获取到选项卡的高度了
APP.vue组件获取组件tabbar选项卡高度,并传到公共状态管理


在影院组件进行判断

公共状态管理文件


浙公网安备 33010602011771号