draggable拖拽约束

如图拖拽标签不会超出外部标签的区域,拖拽约束应该怎么写?
我是用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')
            },

求大神指教拖拽约束

阅读 1.2k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题