Я конвертирую некоторый HTML-код в ReactJS и у меня проблемы с Jquery / JqueryUI.
Я импортирую оба файла с:
import * as jQuery from 'jquery';
import * as jui from 'jquery-ui';
В моем componentDidMount () у меня есть
componentDidMount() {
jQuery(function () {
jQuery("#palettes").accordion({
activate: function (event, ui) {
furniturePalette.requestUpdate();
// wallPartsPalette.requestUpdate();
}
});
jQuery("#openDocument").draggable({ handle: "#openDocumentHandle", stack: ".draggable", containment: 'window', scroll: false });
jQuery('#optionsWindow').draggable({ handle: "#optionsWindowHandle", stack: ".draggable", containment: 'window', scroll: false });
jQuery("#removeDocument").draggable({ handle: "#removeDocumentHandle", stack: ".draggable", containment: 'window', scroll: false });
jQuery("#myOverviewWindow").draggable({ handle: "#myOverviewWindowHandle", stack: ".draggable", containment: 'window', scroll: false });
jQuery('#statisticsWindow').draggable({ handle: "#statisticsWindowHandle", stack: ".draggable", containment: 'window', scroll: false });
jQuery("#selectionInfoWindow").draggable({ handle: "#selectionInfoWindowHandle", stack: ".draggable", containment: 'window', scroll: false });
jQuery("#myPaletteWindow").draggable({ handle: "#myPaletteWindowHandle", stack: ".draggable", containment: 'window', scroll: false });
jQuery("#myPaletteWindow").resize(function () {
furniturePalette.requestUpdate();
//wallPartsPalette.requestUpdate();
});
});
Я использую «jQuery» вместо «$», поскольку «$» используется с другой библиотекой, которую я использую.
Когда я запускаю это, я получаю
TypeError: __WEBPACK_IMPORTED_MODULE_8_jquery__(...).accordion is not a function
Если я заменю 'jQuery' на 'jui', я получу:
TypeError: name.split is not a function
(эта ошибка в подкаталоге jquery-ui).
У кого-нибудь есть решение?
Решение
Просто напишите:
import * as jQuery from 'jquery';
import 'jquery-ui-bundle';