【发布时间】:2023-03-13 21:18:01
【问题描述】:
我正在尝试将此添加到我的 vue 应用程序中 https://jsbin.com/yejehog/edit?html,js,console,output
我已添加到我的代码中,如何将 div id 传递给 Sortable.create?
在我的控制台中,我收到错误 Uncaught Sortable: el` must be an HTMLElement, not [object Null]
import { Sortable, Swap } from 'sortablejs/modular/sortable.core.esm';
Sortable.mount(new Swap());
let list = document.getElementById("list")
Sortable.create(list, {
multiDrag: true,
selectedClass: "selected"
});
<div id="list" v-for="(item, index) in points.pointList.collection">
<p>{{ item.name}}</p>
</div>
这个也试过了
const clueDiv = ref(null)
Sortable.mount(new Swap());
Sortable.create(clueDiv.value, {
multiDrag: true,
selectedClass: "selected"
});
#list(v-for="(item, index) in points.pointList.collection" ref="clueDiv")
同样的错误
【问题讨论】:
标签: javascript vue.js vuejs3