首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >First drag不适用于vue-smooth-dnd vuejs

First drag不适用于vue-smooth-dnd vuejs
EN

Stack Overflow用户
提问于 2019-09-20 19:41:08
回答 1查看 974关注 0票数 0

下面的代码包含一个用于拖放的部分。div拖拽块需要拖拽,但它不起作用,第一次拖拽它就不放了。它从我们第二次拖动时开始下降。

https://github.com/kutlugsahin/vue-smooth-dnd

代码语言:javascript
复制
<div>
   <Container
      @drop="onDrop"
      lock-axis="y"
      drag-class="drag-div"
      drop-class="drag-div"
      drag-handle-selector=".shelf-icon"
      :get-ghost-parent="getGhostParent"
      >
      <Draggable v-for="(link,index) in quick_links" :key="link.name">
         <div class="drag-block">
            <div class="order-number">{{ index + 1 }}</div>
            <div class="content-block">
               <div class="mx-ellipsis">{{ link.name }}</div>
               <small class="mx-color-secondary mx-ellipsis" style="width: 
                  250px;">{{ link.url }}</small>
            </div>
            <div class="shelf-icon">
               <i class="micon-handle-horizontal sort-icon"></i>
            </div>
         </div>
      </Draggable>
   </Container>
</div>
EN

回答 1

Stack Overflow用户

发布于 2019-10-23 15:05:28

这个问题有一个解决办法,我们可以在vue实例的挂载钩子中初始化包装器实例时使用一些延迟。下面的代码显示了示例谢谢。

代码语言:javascript
复制
<template>
  <display-panel @closed="closeDialog">
    <template slot="content">
      <div>
        <div class="section-title">{{$t('edit_display_order')}}</div>
        <div class="divider branding-color" />
        <div
          class="display-order-edit-info"
        ></div>
        <div class="drag-drop-container">
          <Container
            v-if="showDragContainer"
            ref="quickLinkDragDrop"
            @drop="onDrop"
            lock-axis="y"
            drag-class="drag-div"
            drop-class="drag-div"
            drag-handle-selector=".shelf-icon"
            :get-ghost-parent="getGhostParent"
          >
            <Draggable v-for="(link,index) in items" :key="link.name">
              <div class="drag-block">
                <div class="order-number">{{ index + 1 }}</div>
                <div class="content-block">
                  <div class="ellipsis">{{ link.name }}</div>
                  <small class="color-secondary ellipsis" style="width: 250px;">{{ link.url }}</small>
                </div>
                <div class="shelf-icon">
                  <i class="micon-handle-horizontal sort-icon"></i>
                </div>
              </div>
            </Draggable>
          </Container>
        </div>
      </div>
    </template>
  </display-panel>
</template> 

<script>

import { Container, Draggable } from 'vue-smooth-dnd'
export default {
  name: 'DragComponent',
  components: {
    Container,
    Draggable
  },
  props: {
    itemLinks: {
      type: Array,
      default: () => []
    }
  },
  mounted() {
    setTimeout(() => {
      this.showDragContainer = true
    }, 300)
  }
}
</script>
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58027694

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档