From 7a0f8f96440a0266cef811eb95282d836e2a15ee Mon Sep 17 00:00:00 2001 From: haiyangcui Date: Sat, 17 Oct 2020 21:19:05 +0200 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81star=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E7=9A=84=E6=8B=96=E6=9B=B3=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Star.vue | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/src/components/Star.vue b/src/components/Star.vue index 2dbf05a..dff9e75 100644 --- a/src/components/Star.vue +++ b/src/components/Star.vue @@ -7,7 +7,7 @@ 清空 同步所有收藏 -
+
{ this.getFavorites() }) + }, + updateDatabase (data) { + star.clear().then(res => { + var id = length + data.forEach(ele => { + ele.id = id + id -= 1 + }) + star.bulkAdd(data) + }) + }, + rowDrop () { + const tbody = document.getElementById('list-table').querySelector('.el-table__body-wrapper tbody') + const _this = this + Sortable.create(tbody, { + onEnd ({ newIndex, oldIndex }) { + const currRow = _this.list.splice(oldIndex, 1)[0] + _this.list.splice(newIndex, 0, currRow) + _this.updateDatabase(_this.list) + } + }) } }, + mounted () { + this.rowDrop() + }, created () { this.getFavorites() }