拖拽
# 拖拽传参 setData与getData
<span
v-else
:title="item.cameraName"
class="tree-span"
draggable="true"
@dragstart="drag($event, item)"
></span>
1
2
3
4
5
6
7
2
3
4
5
6
7
//组件一:(传递数据的组件)
drag(e, item) {
e.dataTransfer.setData("deviceId", item.id);
e.dataTransfer.setData("playOutputUrl", item.playOutputUrl);
},
//组件二 (接收数据的组件)
drop(e, item) {
let deviceId = e.dataTransfer.getData("deviceId");
let playOutputUrl=e.dataTransfer.getData("playOutputUrl");
}
1
2
3
4
5
6
7
8
9
10
2
3
4
5
6
7
8
9
10
编辑 (opens new window)
上次更新: 2022/12/05