如何使用ES6/ES7语法导入jQuery UI? [英] How to import jQuery UI using ES6/ES7 syntax?

查看:293
本文介绍了如何使用ES6/ES7语法导入jQuery UI?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在我的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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆