标签:parent log efault tno child setw clientx offset rtx
<body>
<div class="main">
<div class="left" v-bind:style="{width:ths[0].width+‘px‘}"></div>
<div class="right" @mousedown="drag"></div>
</div>
<script>
var vm1=new Vue({
el:‘.main‘,
data:{
ths:[
{width:‘30‘},
{width:‘‘}
]
},
methods:{
drag:function(e,index){
var Left=e.target.parentNode.children[0],
leftW=Left.offsetWidth,
startX=e.clientX;
_this=this;
console.log(_this);
document.onmousemove=function(e){
e.preventDefault();
var distX=e.clientX-startX;
Left.style.width=leftW+distX+‘px‘;
if(parseInt(Left.style.width)>=280){
Left.style.width=280+‘px‘;
}
}
document.onmouseup=function(){
document.onmousemove=null;
}
}
}
});
</script>
</body>
标签:parent log efault tno child setw clientx offset rtx
原文地址:http://www.cnblogs.com/yanyufusu/p/7875315.html