我有一个使用 webpack 运行的 React 应用程序,我想使用 jquery UI 使元素可拖动。我已经添加了图书馆
如何将 jquery ui 导入到组件中
错误:(...).draggable 不是函数 $(this.productElm).draggable({
//Install:
yarn add jquery-ui
// Component file:
import $ from "jquery";
import draggable from 'jquery-ui';
export class Item extends React.Component {
componentDidMount(){
this.setPlacement();
document.addEventListener('mousedown', this.handleOutsideClick, false)
this.initInterations()
}
initInterations(){
setTimeout(() => {
$(this.productElm).draggable({
addClasses: false,
stop: (e, ui) => {
if(this.props.onChange){
this.props.onChange({
name: 'move',
x: ui.position.left,
y: ui.position.top
}, this.props.item)
}
}
})
})
}
}