The important part (applied to the Nested Demo on the SortableJS homepage):const nestedQuery = '.nested-sortable';const identifier = 'sortableId';const root = document.getElementById('nestedDemo');function serialize(sortable) { var serialized = []; var children = [].slice.call(sortable.children); for (var i in children) { var nested = children[i].querySelector(nestedQuery); serialized.push({ id: children[i].dataset[identifier], children: nested ? serialize(nested) : [] }); } return serialized}console.log(serialize(root)) 这篇关于SortableJS从嵌套列表中获取订单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-19 21:40