WebStorm 自动完成和自动导入不起作用

Khe*_*raj 0 ide autocomplete webstorm react-native auto-import

我在 WebStorm 中研究 React-Native。

问题一

我有一些类,我想使用 WebStorm 的自动导入功能,它适用于某些类,但不适用于所有类。

当我输入 name 并点击时Ctrl + Space,它不会自动导入类。

无进口建议

Alt + Enter也试过,它在列表中没有导入建议。

没有进口

问题二

然后我手动导入了这个类,现在 WebStorm 无法显示自动完成的方法建议,当我按下 时Ctrl + Space,我的方法没有在那里列出。

图像3

实用程序.js

export function alertMessage(alertMessage) {
  Alert.alert(
    "Alert",
    alertMessage,
    [{ text: "OK", onPress: () => console.log("OK Pressed") }],
    { cancelable: false }
  );
}
Run Code Online (Sandbox Code Playgroud)

是否有一些我遗漏的 WebStorm 设置。我想提高我的生产力。

Sag*_*gar 5

在开发任何(不仅是 react)应用程序时实现正确代码完成的最简单方法是通过 IDE 本身添加对所需类型脚本库的支持。假设您使用Web StormIDE 进行开发:

  • Settings (Ctrl + Alt + S) -> Languages & Frameworks

  • 展开 JavaScript-> 库

  • 使用react时,建议添加:(react; react-dom; react-native用于移动应用开发)

  • Apply完成后点击