UNPKG

vue3-dnd

Version:

Drag and Drop for Vue Composition API

34 lines (33 loc) 846 B
import { defineComponent, watchEffect } from "vue-demi"; export default defineComponent({ props: { connect: { type: Function, required: true }, src: { type: String, required: true } }, setup: function setup(props) { watchEffect(function() { if (typeof Image === "undefined") return; var connected = false; var img = new Image(); img.src = props.src; img.onload = function() { props.connect(img); connected = true; }; return function() { if (connected) { props.connect(null); } }; }); return function() { return null; }; } });