【发布时间】:2017-05-05 13:04:13
【问题描述】:
当我使用 material-ui 包时,我在 Webstorm(ctrl+space)中获得了很好的自动完成功能:
我认为这可能与该包包含 index.es.js 文件的事实有关:
import _AppBar from './AppBar';
export { _AppBar as AppBar };
import _AutoComplete from './AutoComplete';
export { _AutoComplete as AutoComplete };
import _Avatar from './Avatar';
export { _Avatar as Avatar };
import _Badge from './Badge';
export { _Badge as Badge };
import _BottomNavigation from './BottomNavigation';
...
所以我在我的自定义 npm 模块中生成了自己的 index.es.js 并将其放在转译后的 index.js 旁边:
import {ActionTypes as _ActionTypesElements} from './reducers/elements/elements';
export { _ActionTypesElements as ActionTypes };
import {ActionTypes as _ActionTypesAppState} from './reducers/appState/appState';
export { _ActionTypesAppState as ActionTypesAppState };
import _appStateActions from './reducers/appState/appState_actions';
export { _appStateActions as appStateActions };
...
但我没有自动完成:
知道为什么吗?
【问题讨论】:
-
你有安装任何材质插件吗?在
File->Settings->Plugins?你安装你的 npm 模块,比如:npm file-editor install? -
@Edwin 我找到了答案,显然我必须在 package.json 中添加一个名为 jsnext:main 的字段。
标签: javascript intellij-idea npm ecmascript-6 babeljs