PHPStorm JSX/React语法突出显示 [英] PHPStorm JSX/React syntax highlighting

查看:486
本文介绍了PHPStorm JSX/React语法突出显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为当前项目使用PHPStorm 8.0.3,但是不幸的是它不支持JSX.在我的React组件(然后由Browserify编译)中,HTML用红色下划线标出并无效:

I'm using PHPStorm 8.0.3 for my current project, but unfortunately it doesn't support JSX. In my React components (which are then compiled by Browserify) HTML gets underlined in red and invalidated:

这只是一个很小的组成部分,但是对于较大的组成部分肯定会很烦人.同样,代码格式化也无法按预期进行.

This is just a small component, but it surely gets pretty annoying with bigger ones. Also code formatting doesn't work as expected.

  1. 是否有一个(很难找到的)设置能够正确显示语法?
  2. 如果没有这样的设置,是否可以下载相应的软件包?
  3. 如果根本没有支持,如何扩展PHPStorm(也许通过自定义的颜色/语法模式)以在我的js文件中接受HTML?

推荐答案

我遇到了同样的问题,解决方案是在PHPStorm 8上使用JSX Harmony:

I had the same problem and solution is to either use JSX Harmony on PHPStorm 8:

Preferences / Languages & Frameworks / JavaScript

JavaScript language version设置为JSX Harmony

或移至PHPStorm 9 EAP.我希望PHPStorm 9很快就可以使用(因为我在EAP版本中遇到性能问题).

or move to PHPStorm 9 EAP. I hope PHPStorm 9 will be available soon, though (as I had performance issue with EAP version).

这篇关于PHPStorm JSX/React语法突出显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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