【问题标题】:WebStorm not suggesting/autocompleting code for styled-componentsWebStorm 不建议/自动完成样式组件的代码
【发布时间】:2020-06-27 14:05:00
【问题描述】:

我最近从 VSCode 切换到了 WebStorm。但我注意到 WebStorm 并没有建议像 VSCode 这样的样式组件上的属性和道具。不过,它确实建议使用普通的 HTML/JSX。有其他人遇到过问题并知道如何解决吗?

我已经按照之前的建议安装了 react、react-native、react-dom、styled-system 和 styled-components 的类型,但没有成功。

VS代码:

来自 WebStorm 中完全相同的项目的完全相同的代码:

VSCode 甚至建议使用 Styled System 的道具,而 WebStorm 似乎无法做到。我真的很喜欢 WebStorm,但这个问题让我想知道我是否应该切换回去。

2020 MacBook Pro(如果相关)。

【问题讨论】:

    标签: javascript reactjs visual-studio-code webstorm styled-components


    【解决方案1】:

    安装 webstorm-styled-components 插件

    https://styled-components.com/docs/tooling#webstorm-intellij-idea-phpstorm-pycharm-and-rubymine
    https://github.com/styled-components/webstorm-styled-components

    要安装插件,请打开 IDE Preferences | Plugins,然后点击 Browse repositories... 并搜索 Styled Components。

    【讨论】:

    • 好的。 VSC 似乎开箱即用的原因是因为 VSC 的 Babel 插件已经包含样式组件支持
    • 不幸的是,这不起作用,据我所知,我可能必须从 create-react-app 中弹出来更改 babel 配置以运行插件。我发现这很有趣,VSC 开箱即用,而不是 Webstorm,因为 Webstorm 通常看起来更“完整”开箱即用。
    • 您解决了这个问题吗?我安装了样式组件插件,但仍然没有得到任何建议
    • 在一个项目中为我工作,而不是另一个......
    【解决方案2】:

    只需安装 @types/styled-components 包。它没有得到类型信息这是怎么回事。

    【讨论】:

      猜你喜欢
      • 2021-08-28
      • 1970-01-01
      • 2014-10-15
      • 2020-07-28
      • 1970-01-01
      • 2019-09-27
      • 2022-01-12
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多