Vuejs实现拖拽效果


<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>


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM