0
雖然在手動拖放中,但我沒有在自定義事件中獲取dataTransfer.types,但類型被設置爲類型:Array(1)。可有人請指正在初始化這個dataTransfer對象。(瀏覽器:鉻)正確的方式來初始化JavaScript中的CustomEvent dataTransfer對象
function createCustomEvent(type) {
var event = new CustomEvent("CustomEvent", {"cancelable": true})
event.initCustomEvent(type, true, true, null);
event.dataTransfer = {
data: {
},
setData: function(type,val) {
this.data[type] = val
},
getData: function(type) {
return this.data[type]
},
dropEffect: 'move',
effectAllowed:'move',
types: [],
items: {},
files:{}
}
return event
}