问题
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?
回答1:
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.
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 Regular Install:
C:\Users<b>YourUserName\AppData\Roaming\Sublime Text 3\Packages
- Windows Portable Install:
InstallationFolder\Sublime Text 3\Data\Packages
You will also want to place the JSX Comments.tmPreferences file in the same directory so that comments work properly.
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.
来源:https://stackoverflow.com/questions/64528395/syntax-highlighting-error-of-jsx-in-sublime-text