首页 > 编程语言 > 详细

使用[].forEach.call()方法的写拖拽排序。

时间:2018-07-11 17:27:48      阅读:198      评论:0      收藏:0      [点我收藏+]

---恢复内容开始---

技术分享图片例子:
function
registerDrag() {
[].forEach.call(ImgSortable.getElementsByClassName(‘unload-show‘), function (el){
Sortable.create(el, {
group: ‘photoGroup‘,
animation: 1050
});
});
}
要引用两个插件:
  <script src="./jquery.1.12.4.min.js"></script>
  <script src="./Sortable.js"></script>

[].forEach.call的写法理解:
    1.来源 : 是根据 document.querySelectorAll(‘div‘)写法扩展的;
   2.[] : 代表的是一个空数组。 作用:用来引出forEach方法,
   3. .forEach : javaScript常用的遍历元素的方法。 作用遍历元素集合(数组)。
    4. .call : 解析:调用对象,并替换掉当前对像。 作用替换对象。
方法解析:
  [].forEach.call() : 遍历数组【替换对象
  参数:ImgSortable.getElementsByClassName(‘unload-show‘), :替换后的对象【你要遍历的数组名】,
  方法:作用排序
   function (el){
Sortable.create(el, {
group: ‘photoGroup‘,
animation: 1050
});

    el : 形参
    Sortable : 控件的名称。
    .create : 控件的方法
    group(参数) :自定义名称,
    animation : 动画时间


---恢复内容结束---

使用[].forEach.call()方法的写拖拽排序。

原文:https://www.cnblogs.com/blue-Censer/p/9295686.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!