如何在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.

  1. 打开命令面板.
  2. 键入change language mode
  3. Enter
  4. 键入javascript react
  5. Enter
  1. Open the commands palette.
  2. Type change language mode
  3. Press Enter
  4. Type javascript react
  5. 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.