Deprecated: parse_url(): Passing null to parameter #1 ($url) of type string is deprecated in /www/wwwroot/blog_qqvbc_com/usr/plugins/Access/Access_Core.php on line 339

Deprecated: parse_url(): Passing null to parameter #1 ($url) of type string is deprecated in /www/wwwroot/blog_qqvbc_com/usr/plugins/Access/Access_Core.php on line 392

Deprecated: parse_url(): Passing null to parameter #1 ($url) of type string is deprecated in /www/wwwroot/blog_qqvbc_com/usr/plugins/Access/Access_Core.php on line 394
vue使用sortable在更新排序后更新数据的顺序 - Joyber 的博客

该项目是使用混合代码的PHP项目,用了VUE,使用了sortable对数据进行手动排序,存在的问题是html更新排序后,需要对VUE的数据进行更新,如下是JS片段:

                //排序功能
                let sortable = new Sortable(this.$refs.sortTable, {
                    animation: 150,
                    handle: '.sort-handler',
                    filter: '.sort-filter',
                    draggable: '.sort-item',
                    onUpdate: function (evt) {
                        // console.log(evt);
                        // console.log(evt.newIndex , evt.oldIndex)
                        const {groups} = vm
                        if (evt.newIndex > evt.oldIndex) {
                            groups.splice(evt.newIndex, 0, groups[evt.oldIndex - 1])
                            groups.splice(evt.oldIndex - 1, 1)
                        } else {
                            groups.splice(evt.newIndex - 1, 0, groups[evt.oldIndex - 1])
                            groups.splice(evt.oldIndex, 1)
                        }
                        vm.saved = false
                    }
                });

标签: none

添加新评论