我想使用 Jquery UI 在 React 中實作 Resizable 。
我有這樣的代碼..
import $ from 'jquery';
import 'jquery-ui';
...
...
useEffect(() => {
$(function () {
$(".resizable").resizable();
});
}, [])
...
...
<div className="resizable" >Test</div>
我沒有收到錯誤,但可調整大小不起作用...
我想要這樣jqueryui.com/resizable
uj5u.com熱心網友回復:
試試這個
一、安裝jquery-ui-bundle
npm install jquery-ui-bundle --save
然后,
import React, { useEffect, useRef } from 'react';
import $ from 'jquery';
import 'jquery-ui-bundle';
import 'jquery-ui-bundle/jquery-ui.css';
...
...
const ref = useRef();
useEffect(() => {
$(function () {
$(ref.current).resizable();
});
}, [ref.current]);
...
...
<div className="resizable" ref={ref}>Test</div>
在使用谷歌搜索時我發現jquery-ui我們可以匯入單個小部件(可能非常麻煩)或安裝jquery-ui-bundle并只匯入一次。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/407478.html
標籤:
上一篇:QT快速布局按百分比分割
