Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
4.4k views
in Technique[技术] by (71.8m points)

vue vuedraggable start end方法不生效

<draggable
          v-model="imageList"
          :options="options"
          filter=".undraggable"
          @update="dataragEnd"
          @change="change"
          @start="start"
          @end="end"
        >
          <!-- <transition-group> -->
          <block v-for="item in imageList" class="imgList" :key="item.url">
            <view class="uni-uploader__file">
              <image
                class="uni-uploader__img"
                :src="item.url"
                :data-src="item.url"
                @touchstart="gtouchstart(item, $event)"
                @touchmove="gtouchmove(item, $event)"
                @touchend="gtouchend(item, $event)"
                @tap="previewImage(item)"
              ></image>
            </view>
          </block>
        </draggable>
        
    data() {
        return {
        
      options: {
        delayOnTouchOnly: true, //开启触摸延时
        // direction: 'vertical',   //拖动方向
        delay: 500, //延时时长
        touchStartThreshold: 3, //防止某些手机过于敏感(3~5 效果最好)
        chosenClass: "chosen", //选中之后拖拽项添加的class名(用于选中时候添加样式)
        scroll: false
      },
        }
    }

拖动的时候报错 Cannot read property 'id' of null",start,end函数没生效

@start="start"
@end="end"
这两个方法删除就没有报错了。请问什么原因?
image.png
chunk-vendors.js:35055 [Vue warn]: Error in v-on handler: "TypeError: Cannot read property 'id' of null"


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

字面意思未能读取到id,你可以尝试设置 id 试试


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...