拖放
将元素拖动到目标元素或位置。
信息
此命令的功能很大程度上取决于你的应用中拖放的实现方式。如果你遇到问题,请在 #4134 中发布你的示例。
用法
$(selector).dragAndDrop(target, { duration })
参数
名称 | 类型 | 详情 |
---|---|---|
target | Element, DragAndDropCoordinate | 目标元素或包含x和y属性的对象 |
options 可选 | DragAndDropOptions | dragAndDrop命令选项 |
options.duration 可选 | Number | 拖动应持续多长时间 |
示例
example.test.js
it('should demonstrate the dragAndDrop command', async () => {
const elem = $('#someElem')
const target = $('#someTarget')
// drag and drop to other element
await elem.dragAndDrop(target)
// drag and drop relative from current position
await elem.dragAndDrop({ x: 100, y: 200 })
})