[Vuejs]-How do I pass the div element outside setup function

1👍

First the list id should be added to the wrapper element that contains the items rendered using v-for then use onMounted hook to run init the sortable function :

<div id="list" ref="clueDiv">
  <div  v-for="(item, index) in points.pointList.collection">
   <p>{{ item.name}}</p>
  </div>
</div>

and :

 const clueDiv = ref(null)

onMounted(()=>{
 Sortable.mount(new Swap());

    Sortable.create(clueDiv.value, {
      multiDrag: true,
      selectedClass: "selected"
    });
})
 

Leave a comment