如何使用 ES6/ES7 语法导入 jQuery UI? [英] How to import jQuery UI using ES6/ES7 syntax?
问题描述
我正在尝试在我的 reactJS/Redux 应用程序中使用一些 jQuery UI 功能.我已经使用以下方法导入了 jQuery 和 jQuery UI:
I am trying to use some jQuery UI functionality in my reactJS/Redux application. I've imported both jQuery and jQuery UI using:
npm install jquery jquery-ui
然后我试过了:
import $ from 'jquery';
import jQuery from 'query';
import jQuery-ui from 'jquery-ui';
但是,当我尝试执行以下操作时,似乎没有导入 jQuery UI:
However jQuery UI does not seem to be imported when I try to do something like:
componentDidMount() {
$('ol#myList').selectable();
}
我认为问题出在 jQuery UI 上.我究竟做错了什么?我怎样才能让 jQuery UI 与这个堆栈一起工作?
I believe the issue is with jQuery UI. What am I doing wrong? How can I get jQuery UI to work with this stack?
谢谢!
推荐答案
我成功地使用了 jquery-ui 的部分导入.我的意思是只从 jquery-ui 中导入我需要的模块:
I'm successfully using partial import from jquery-ui. I mean import to my module only what I needed from jquery-ui:
import $ from 'jquery';
import 'jquery-ui/themes/base/core.css';
import 'jquery-ui/themes/base/theme.css';
import 'jquery-ui/themes/base/selectable.css';
import 'jquery-ui/ui/core';
import 'jquery-ui/ui/widgets/selectable';
(但考虑到我正在使用 webpack https://webpack.github.io/, 在其他环境中方法可能不同)
( But take in account that I'm using webpack https://webpack.github.io/, in other environment approach may differ)
这篇关于如何使用 ES6/ES7 语法导入 jQuery UI?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!