- 当前 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>
移动端建议用 touchmove 代替
谢谢您!
真香。
已解决谢谢。
提供下代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)。
https://developers.weixin.qq.com/s/b63O6Mmw7i4y