简体   繁体   English

React.js在Sublime中突出显示奇怪的语法

[英]React.js Strange Syntax Highlighting in Sublime

在此输入图像描述

While following a React.js tutorial, I notice that the syntax highlighting in Sublime Text 3 looks strange, especially after the closing </h1> tag. 在遵循React.js教程时,我注意到Sublime Text 3中的语法突出显示看起来很奇怪,特别是在关闭</h1>标记之后。

Is there a way to allow Sublime Text to do proper syntax highlighting such as this? 有没有办法允许Sublime Text进行适当的语法高亮,比如这样?

You need to install a plugin that recognizes JSX. 您需要安装一个识别JSX的插件。 Babel sublime is great. 巴贝尔崇高是伟大的。 Once you get that installed you can set your syntax to Babel (JavaScript) instead of just JavaScript. 安装完成后,您可以将语法设置为Babel(JavaScript),而不仅仅是JavaScript。

Here's a blog post on setting up Sublime for React.js. 这是关于为React.js设置Sublime的博客文章。 It shows you how to set the default syntax highlighting to babel. 它向您展示了如何设置突出显示为babel的默认语法。 In the tutorial it does it for .jsx extensions, but I did it for .js and it works great for all JavaScript. 在本教程中,它为.jsx扩展做了它,但我为.js做了它,它适用于所有JavaScript。

http://cheng.logdown.com/posts/2015/07/10/setup-sublime-text-3-for-reactjs-development http://cheng.logdown.com/posts/2015/07/10/setup-sublime-text-3-for-reactjs-development

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM