大佬教程收集整理的这篇文章主要介绍了如何在 setup 函数之外传递 div 元素,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在尝试将此添加到我的 vue 应用程序中 https://jsbin.com/yejehog/edit?html,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")
同样的错误
首先应该将 list
id 添加到包含使用 v-for 呈现的项目的包装元素,然后使用 onMounted
钩子运行 init 可排序函数:
<div id="list" ref="clueDiv">
<div v-for="(item,indeX) in points.pointList.collection">
<p>{{ item.namE}}</p>
</div>
</div>
和:
const clueDiv = ref(null)
onMounted(()=>{
Sortable.mount(new Swap());
Sortable.create(clueDiv.value,{
multiDrag: true,SELEctedClass: "SELEcted"
});
})
以上是大佬教程为你收集整理的如何在 setup 函数之外传递 div 元素全部内容,希望文章能够帮你解决如何在 setup 函数之外传递 div 元素所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。