如图拖拽标签不会超出外部标签的区域,拖拽约束应该怎么写?
我是用vue写的,网上查的draggable组件
代码如下
模板代码
<div
class="notpayattentionto_wrap"
@drop="nohasDrop()"
@dragover="nohasDragOver()">
<div class="custom_contents_title">
<span>未关注</span>
</div>
<div
class="custom_contents">
<draggable
v-model="follow_nohas_contents"
:options="{group:'people'}"
@handledraggable="handleDraggable($event)"
class="custom_nohas_draggable">
<div
class="custom_nohas_contents"
:class="[nowclicknohas===index ? 'custom_draggable' : '',nohashover===index ? 'custom_nohas_hover' : '']"
v-for="(list,index) in follow_nohas_contents"
draggable="true"
@dragstart="nohasDrag(index)"
@click="joinNoHasContents(index)"
@mouseenter="nohashover=index"
@mouseleave="nohashover=''">
<div class="contents_icon"></div>
<div class="contents_main">
<span class="contents_main_text">
{{ list.name }}
</span>
</div>
</div>
</draggable>
<div class="div_clear"></div>
</div>
</div>
js部分
/* 未关注的拖拽和释放 */
// 拖拽元素时触发
nohasDrag: function(index){
this.nowclicknohas=index;
console.log('nohasDrag')
},
// 在区域内释放时触发
nohasDrop: function(){
this.nowclickhas='';
this.nowclicknohas='';
console.log('nohasDrop')
},
// 在区域内触发
nohasDragOver: function(){
console.log('nohasDragOver')
},
求大神指教拖拽约束