2024-07-12
한어Русский языкEnglishFrançaisIndonesianSanskrit日本語DeutschPortuguêsΕλληνικάespañolItalianoSuomalainenLatina
For example, I need to get the data of the current dragged element in the function that starts dragging, mainly by adding custom attributes to the element.
If you need to get an attribute id in a loop list, thenCustomize an attribute myidBind to an element.
Of course: if you want to pass in multiple values, you can concatenate them together and finally process them according to the required values.
Eg: :myid="item.id+','+item.schoolId" By binding multiple values to one attribute in this way, it is convenient to use.
The following code shows that I only need one attribute, so I only bind one.
- <VueDraggable
- v-model="List"
- @start="onDragStart(list,$event)"
- :animation="150"
- group="people"
-
- >
- <div
- v-for="(item, index) in List"
- @click.prevent="subClick(item, index)"
- @mousemove="handleMouseMove(item, index)"
- :key="item.id"
- :myid="item.id"
-
- >
-
- 一些要拖拽的模块内容
- </div>
- </VueDraggable>
passe.item.attributes.myid.valueNote: e is the event object.
- const onDragStart = (list,e) => {
- delEleIndex.value=e.oldIndex;
- curList.value=list;
- draggedElement.value = e.item.attributes.myid.value;
- console.log("===当前拖元素的id==",draggedElement.value);
- };