如何在VSCode中自动缩进jsx
问题描述:
VSCode似乎不会在jsx中自动缩进HTML元素?
VSCode seems doesn't auto indent HTML elements in jsx?
有什么办法可以解决它.
Is there any way to fix it.
更新:
在 Atom 中:
当我输入<div>
时,原子将显示:
When I input <div>
, atom will show:
按return
键后,结果为(注意光标的位置):
After I press the return
key, the result is(pay attention to the location of the cursor):
在 VSCode 中:
答
尝试将语言模式更改为JavaScript React.
Try changing the language mode to JavaScript React.
- 打开命令面板.
- 键入
change language mode
- 按 Enter
- 键入
javascript react
- 按 Enter
- Open the commands palette.
- Type
change language mode
- Press Enter
- Type
javascript react
- Press Enter
完成后,您将在左下角看到JavaScript React模式.
Once that's done, you'll see the JavaScript React mode in the bottom left corner.
一旦处于该模式,请再次尝试格式化文档.
Once you're in that mode, try again to format the document.