图片拖拽功能的实现

1. 引入js库 (js下载地址:https://github.com/SortableJS/Sortable)

<script src="/static/js/sortable.min.js"></script>

2. 拖拽的使用

      /**
       * 图片拖拽函数(先允许图片拖拽,然后在上传的时候再去对比数据)
       * @param imageElementName
       * @param imageData
       */
      function draggingAndPulling(imageElementName) {
          // 图片拖拽
          var imageElement = document.getElementById(imageElementName); // 要拖拽的div的名称
          if (imageElement != null) {
              new Sortable(imageElement, {});
          }
      }

3. 拖拽其实并不难,难的是对拖拽之后的图片进行排序,然后再保存到数据库中进行存储,这个就要视情况而定了。

猜你喜欢

转载自www.cnblogs.com/cjjjj/p/10418441.html