Bootstrap

draggable拖拽列表设置某一条元素禁止被拖拽

draggable拖拽列表设置某一条元素禁止被拖拽

filter=“.unmover”
:class=“{unmover:index===0}”
表示当前不能被拖拽

 <draggable v-model="imgFile" animation="400" class="clearfix" @update="datadragEnd" filter=".unmover" :move="onMove">
          <div class="leftbox" v-for="(item,index) in imgFile" :key="index" :class="{unmover:index===0}">
              <div class="left">
                   <img :src="item.url" alt="" />
                   <div class="content-wrap">
                      <div class="content">
                        <i class="el-icon-zoom-in" @click.stop="showImg(item.url)"></i>
                        <i class="el-icon-delete" @click.stop="delImg(item,index)"></i>
                      </div>
                   </div>
              </div>
              <p class="img-title">{{index==0?'封面图':'详情图'}}</p>
         </div>
</draggable>

:move=“onMove” 表示不能被停靠,其他元素不可以与当前元素调换位置

onMove (e) {
      //relatedContext: 将停靠的对象,设置为false表示不允许停靠和拖拽
      let evl = e.relatedContext.element.sequence
      if (evl == 1) return false;
      return true
},
;