1. 设置头
<meta charset="utf-8" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport" />
2.css
<style>
html, body {
margin: 0;
height: 100%;
width: 100%;
overflow: hidden;
}
.index_body {
overflow-y: hidden;
height: 100%;
position: fixed;
}
</style>
3.js (需要引用jquery) 不想依赖的话自己修改下,。
<script type="text/javascript">
$('body').on('touchmove', function (event) {
event.preventDefault();
});
if(window.navigator.userAgent.toLowerCase().match(/MicroMessenger/i) == 'micromessenger'){
$('body').addClass('index_body');
}else{
$('body').removeClass('index_body');
}
</script>