【发布时间】:2020-07-20 18:34:12
【问题描述】:
我正在尝试复制一个拖放任务,例如 trello link
现在,我如何在MyComponent.vue 的方法中调用dragdrop.js 的函数?
这就是我所做的......
我的组件.vue
<template>
....simple html drag and drop structure goes here
</template>
<script>
import dragdrop from './dragdrop.js';
export default {
name: 'my-component',
components: {},
data: () => ({
dragdrop : dragdrop
}),
methods: {
dragStart(e) {
this.dragdrop.dragStart(e);
},
dropIt(e) {
this.dragdrop.dropIt(e);
},
allowDrop(e) {
this.dragdrop.allowDrop(e);
}
}
}
</script>
拖放.js
function dragStart(ev) {
....
}
function dropIt(ev) {
....
}
function allowDrop(ev) {
}
开始拖动时出现此错误:
VM12491 tickets:36 Uncaught ReferenceError: dragStart is not defined
at HTMLDivElement.ondragstart (VM12491 tickets:36)
VM12492 tickets:36 Uncaught ReferenceError: allowDrop is not defined
at HTMLDivElement.ondragover (VM12491 tickets:36)
【问题讨论】:
标签: javascript html vue.js vue-component