HTML5 chrome 中 event.dataTransfer.setData(mimeType, angular.toJson(item)) 后未设置拖放 dataTransfer.types
HTML5 DragDrop dataTransfer.types not set after event.dataTransfer.setData(mimeType, angular.toJson(item)) in chrome
我正在使用 druska/native_js_drag_and_drop_helper.js 来自动化 angular-drag-and-drop-lists
问题:
即使在 event.dataTransfer.setData(mimeType,angular.toJson(item))
之后
dataTransfer.types
未设置或可能不允许在拖放事件中读取
观察:在手动拖放 dragstart 事件期间
dataTransfer {dropEffect: "none", effectAllowed: "move", items: DataTransferItemList, types: Array(1), files: FileList}
dropEffect:"move"
effectAllowed:"move"
files:FileList
items:DataTransferItemList
types:Array(0)
__proto__:DataTransfer
DataTransferItemList {0: DataTransferItem, length: 1}
length: 0
__proto__: DataTransferItemList
DataTransferItem {kind: "string", type: "application/x-dnd"}
kind: ""type: ""
__proto__: DataTransferItem
观察:使用自定义事件时
dataTransfer:Object
data:Object
application/x-dnd:"[{"id":"706","title":"Ab 2","drag":false,"selected":true}]"
__proto__:Object
dropEffect:"move"
effectAllowed:"move"
getData:function (type)
setData:function (type,val)
files:Object
items:Object
types:Array(0)
我正在使用
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:{}
}
我无法初始化 dataTransfer 对象。
dataTransfer.items 和 dataTransfer.types 只读 属性 ,我不知道如何正确
初始化它们 .MDN dataTransfer
问题是 setData dint 有设置 DataTransfer.types 的代码,angular-拖放列表在拖放过程中使用了该代码。
setData: function(type,val) {
this.data[type] = val
this.types[0] = type
}
以上更改解决了问题。现在使用本机 js 拖放工作正常
我正在使用 druska/native_js_drag_and_drop_helper.js 来自动化 angular-drag-and-drop-lists
问题:
即使在 event.dataTransfer.setData(mimeType,angular.toJson(item))
dataTransfer.types
未设置或可能不允许在拖放事件中读取
观察:在手动拖放 dragstart 事件期间
dataTransfer {dropEffect: "none", effectAllowed: "move", items: DataTransferItemList, types: Array(1), files: FileList}
dropEffect:"move"
effectAllowed:"move"
files:FileList
items:DataTransferItemList
types:Array(0)
__proto__:DataTransfer
DataTransferItemList {0: DataTransferItem, length: 1}
length: 0
__proto__: DataTransferItemList
DataTransferItem {kind: "string", type: "application/x-dnd"}
kind: ""type: ""
__proto__: DataTransferItem
观察:使用自定义事件时
dataTransfer:Object
data:Object
application/x-dnd:"[{"id":"706","title":"Ab 2","drag":false,"selected":true}]"
__proto__:Object
dropEffect:"move"
effectAllowed:"move"
getData:function (type)
setData:function (type,val)
files:Object
items:Object
types:Array(0)
我正在使用
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:{}
}
我无法初始化 dataTransfer 对象。 dataTransfer.items 和 dataTransfer.types 只读 属性 ,我不知道如何正确 初始化它们 .MDN dataTransfer
问题是 setData dint 有设置 DataTransfer.types 的代码,angular-拖放列表在拖放过程中使用了该代码。
setData: function(type,val) {
this.data[type] = val
this.types[0] = type
}
以上更改解决了问题。现在使用本机 js 拖放工作正常