经过dom层层注释缩小反馈终于找到问题所在。问题经过问题经过我在弹起弹窗的时候,设置了popupVisible为true然后触发了vue的updated生命周期钩子函数然后我在这个函数里面做了去this.$refs.container.offsetHeight导致页面重绘然后就导致了底部页面向上滚动解决办法解决办法去掉updated函数里面的重绘方法补充知识:项目总结之关于vue中使用mint-ui的mt-popup出现滚动穿透问题的解决总结补充知识:补充知识:项目总结之关于vue中使用mint-ui的mt-popup出现滚动穿透问题的解决总结说实话,使用Mint-ui这个ui组件的过程中遇到了很多问题,这个ui组件问题真多。先说今天的主题吧,我在使用popup选择框的时候和datepicker时间选择器的时候出现了滚动穿透的问题,特别是在ios上面。找了好多方法,最后同事给出了一个好的方法,很简洁,于是就想着总结下来。防止滚动穿透 只需加入@touchmove.native.stop.prevent 阻止默认根元素的默认事件就可以了,native是关键,这个表示根元素的意思,也就是body或者html代码如下:Popup组件:Popup组件:

v-model="popupVisible"

position="bottom">

...



// 防止滚动穿透 只需加入@touchmove.native.stop.prevent 阻止默认根元素的默认事件就可以了native是关键,这个表示根元素的意思,也就是body或者html


v-model="popupVisible"

position="bottom"

@touchmove.native.stop.prevent>

...



v-model="popupVisible"

position="bottom">

...



// 防止滚动穿透 只需加入@touchmove.native.stop.prevent 阻止默认根元素的默认事件就可以了native是关键,这个表示根元素的意思,也就是body或者html


v-model="popupVisible"

position="bottom"

@touchmove.native.stop.prevent>

...


注意当mt-popup中还有div等子元素的时候,一定要注意,这个时候可能会有一些问题,会出现mt-popup这个元素也滚动不了的情况,所以说如果mt-popup本身不需要滚动的话,加了@touchmove.native.stop.prevent,底部页面就不会跟着滑动,如果mt-popup里面有滚动条需要滚动的话,可能就滚动不了,这个时候需要采取常规方法了,如下:
// 解决方式,通过监听popupVisible变量,在弹窗出现后禁止body节点touchMove事件,弹窗消失后恢复body节点的touchMove事件
//html 如下


v-model="popupVisible"

position="bottom">

...



// js 如下

const handler = function(e) {

e.preventDefault();

}



// vue实例内

watch: {

popupVisible: function (val) {

if(val) {

document.getElementsByTagName('body')[0].addEventListener('touchmove', this.handler, { passive: false });

} else {

document.getElementsByTagName('body')[0].removeEventListener('touchmove', this.handler, { passive: false });

}

}

}
//html 如下


v-model="popupVisible"

position="bottom">

...



// js 如下

const handler = function(e) {

e.preventDefault();

}



// vue实例内

watch: {

popupVisible: function (val) {

if(val) {

document.getElementsByTagName('body')[0].addEventListener('touchmove', this.handler, { passive: false });

} else {

document.getElementsByTagName('body')[0].removeEventListener('touchmove', this.handler, { passive: false });

}

}

}Datetime Picker:Datetime Picker:

ref="picker"

type="time"

v-model="pickerValue"

@touchmove.native.stop.prevent>


ref="picker"

type="time"

v-model="pickerValue"

@touchmove.native.stop.prevent>

对于时间组件加了@touchmove.native.stop.prevent,选择时间滚动的时候底部页面就不会跟着滚动了,很完美。@touchmove.native.stop.prevent可以使我们省好多事,用起来吧!以上这篇vue 解决mintui弹窗弹起来,底部页面滚动bug问题就是小编分享给大家的全部内容了,希望能给大家一个参考。