首页 > 解决方案 > 为什么 React 组件代码不会自动缩进?

问题描述

我正在使用带有 React 的 Visual Studio Code。但是代码缩进不会自动应用 - 我必须手动执行它。似乎使用文本编辑器。

示例代码:

<Toolbar tabbar bottom slot="fixed">
        <Link bgColor="primary" textColor="white" onClick={() => AcceptOrder(self, order)}>
          <strong>
            {RootScope.t['Accept order']}
          </strong>
        </Link>
      </Toolbar>

我正在使用 ES7 React/Redux/GrapQL 扩展。

标签: reactjsvisual-studio-codeindentation

解决方案


你使用任何Prettier规则吗?

此外,vscode 中的默认代码格式化快捷方式Shift+Alt+F可以在https://code.visualstudio.com/docs/getstarted/keybindings中查看


推荐阅读