在 React 上拖放时出现错误“t..drop is not a function at content”

问题描述 投票:0回答:0

当我使用“e.preventDefault()”时,它会在控制台中生成一个错误,将一个元素放在另一个元素上。 当我不写“e.preventDefault()”时,没有错误,但我的 DragAndDrop 不起作用。

这是错误:

Uncaught TypeError: t.drop is not a function
    at content.js:1:38480
    at Object.handleEvent (content.js:1:41982)
(
export default function Dashboard() {

    const dragOverHandler = (e) => {
        e.preventDefault()
    }

    return (

        <div>
            <div id='1' draggable={true}
                onDragOver={(e) => dragOverHandler(e)}
            >one element
            </div>
            <div id='2' draggable={true}
                onDragOver={(e) => dragOverHandler(e)}
            >another element
            </div>
        </div>

    )
}

一切正常,但我无法消除错误

reactjs drag drop
© www.soinside.com 2019 - 2024. All rights reserved.