崇高文本中jsx的语法高亮错误 [英] syntax highlighting error of jsx in sublime text
问题描述
我正在尝试在 sublime 文本中构建 React 组件,但是语法突出显示表明我没有正确完成所有操作.哪里错了?
I am trying to construct react components in sublime text, but the syntax highlighting is suggesting that I didn't do everything properly. Where is wrong?
推荐答案
您最有可能使用 Javascript 语法定义,它不能像这样识别内联 HTML.要解决此问题,请尝试使用 JSX.sublime-syntax
来自 Sublime Text 4 的定义,目前正在开发中.
You are most likely using the Javascript syntax definition, which does not recognize inline HTML like this. To fix this, try the JSX.sublime-syntax
definition from Sublime Text 4, which is in development now.
要安装它,请将 .sublime-syntax
文件从上面的链接复制到您的 Packages/User
目录,其中 Packages
是选择 Preferences → Browse Packages…
时打开的一个:
To install it, copy the .sublime-syntax
file from the above link to your Packages/User
directory, where Packages
is the one opened when selecting Preferences → Browse Packages…
:
- Linux:
~/.config/sublime-text-3/Packages
- OS X:
~/Library/Application Support/Sublime Text 3/Packages
- Windows 常规安装:
C:\UsersYourUserName\AppData\Roaming\Sublime Text 3\Packages
- Windows 便携式安装:
InstallationFolder\Sublime Text 3\Data\Packages
- Linux:
~/.config/sublime-text-3/Packages
- OS X:
~/Library/Application Support/Sublime Text 3/Packages
- Windows Regular Install:
C:\Users<b>YourUserName\AppData\Roaming\Sublime Text 3\Packages
- Windows Portable Install:
InstallationFolder\Sublime Text 3\Data\Packages
您还需要放置 JSXComments.tmPreferences
文件在同一目录中,以便注释正常工作.
You will also want to place the JSX Comments.tmPreferences
file in the same directory so that comments work properly.
要使用新的 JSX 语法突出显示,请选择 View → Syntax → User → JSX
.带有 .jsx
后缀的文件应该会自动以正确的语法打开.
To use the new JSX syntax highlighting, select View → Syntax → User → JSX
. Files with the .jsx
suffix should be opened with the correct syntax automatically.
这篇关于崇高文本中jsx的语法高亮错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!