收藏
回答

web-view 页面mousemove失效

框架类型 问题类型 API/组件名称 终端类型 微信版本 基础库版本
小程序 Bug web-view 工具 v1.02 2.4.0

- 当前 Bug 的表现(可附上截图)


- 预期表现


- 复现路径


- 提供一个最简复现 Demo


h5 代码

<script src="http://cdn.bootcss.com/jquery/2.2.3/jquery.js"></script>
<div id="mouseMove">
<span id="span" style="color: red"></span>
<button id="movebtn" style="width: 100px;height: 100px;">拖动我</button>

</div>

<script>
var num = 0;
$().ready(function(){
console.log('begin move')


document.getElementById("movebtn").addEventListener("mousedown", function(e){
document.getElementById("span").innerHTML = e.clientX + ',' + e.clientY
drag(document.getElementById("movebtn"))
   });
})

/**
  * elementToDrag mousedown 事件的元素
  * @param elementToDrag
  * @param event
  */
 function drag(elementToDrag){
document.addEventListener("mousemove", moveHandler, true);
document.addEventListener("mouseup", upHandler, true);

function moveHandler(e){
num++;
document.getElementById("span").innerHTML = e.clientX + ',' + e.clientY
console.log(e.clientX + ',' + e.clientY)

if(e.stopPropagation)
e.stopPropagation();
else
       e.cancelBubble = true;
}

function upHandler(e){
document.removeEventListener("mousemove", moveHandler, true);
document.removeEventListener("mouseup", upHandler, true);

console.log(3);

if(e.stopPropagation)
e.stopPropagation();
else
       e.cancelBubble = true;
}
}
</script>


回答关注问题邀请回答
收藏

3 个回答

登录 后发表内容