jQuery UI在React.js中可调整大小

jQuery UI Resizable in React.js

本文关键字:可调整 js UI React jQuery      更新时间:2023-09-26

我有一个react组件,我正试图在其中实现一个可调整大小的jQuery ui。我对React.js还很陌生,尽管div确实可以拖动,但它并不能调整大小。

这是代码

export default class Element extends AppComponent {
  componentDidMount() {
    // store the node on the `this.node` so we can access elsewhere
    this.node = ReactDOM.findDOMNode(this);
    //make self draggable
    $(this.node).draggable();
    //make self resizable
    $(this.node).resizable({
      handles: "n, e, s, w, ne, nw, se, sw",
      containment: 'parent',
      minHeight: "1px",
      minWidth: "1px",
      start: function(){},
      resize: function(){}
    });
  }
  render(){
    return(
      <div class="element-wrapper" style={this.props.elementStyle}>
      </div>
    );
  }
}

要使用jQuery UI可调整大小,还需要添加jQuery UI CSS文件。包括这两个工作

https://code.jquery.com/ui/1.13.1/themes/smoothness/jquery-ui.css
https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js