|
|
|
|
@ -11,7 +11,7 @@
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script setup>
|
|
|
|
|
import { ref, onMounted, onBeforeUnmount } from "vue";
|
|
|
|
|
import { ref } from "vue";
|
|
|
|
|
|
|
|
|
|
const button = ref(null);
|
|
|
|
|
let startX, startY, posX, posY, mouseMoveTracker, mouseUpTracker;
|
|
|
|
|
@ -56,26 +56,6 @@ const dragButton = (event) => {
|
|
|
|
|
};
|
|
|
|
|
document.addEventListener("touchend", mouseUpTracker);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
onMounted(() => {
|
|
|
|
|
if (!button.value) {
|
|
|
|
|
var child = document.getElementById("draggable-button");
|
|
|
|
|
if (!document.body.contains(child)) {
|
|
|
|
|
document.body.appendChild(button.value);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
onBeforeUnmount(() => {
|
|
|
|
|
if (button.value) {
|
|
|
|
|
var child = document.getElementById("draggable-button");
|
|
|
|
|
if (document.body.contains(child)) {
|
|
|
|
|
document.body.removeChild(child);
|
|
|
|
|
} else {
|
|
|
|
|
console.log("节点不是父节点的子节点");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style>
|
|
|
|
|
|