在 VSCode 中折叠样式组件常量

Tit*_*hos 3 reactjs visual-studio-code styled-components next.js

我一直在 NextJS/React 中使用样式化组件,我喜欢它。通常,我将我的样式分解成单独的 js 文件,但由于我对 React、props、hook 和 context 等相对较新,我经常发现需要将我的样式保留在我的组件文件中。我的问题是如何在 VSCode 中折叠以下代码:

const SomeStyledComponent = styled.div`
  height: 300px;
  width: 300px;
  ...
`;
Run Code Online (Sandbox Code Playgroud)

让我的编码生活更轻松将大有帮助。

谢谢你

Mar*_*tin 10

您可以使用indentation代码折叠策略。

// settings.json
{
//  ...other settings
    "editor.foldingStrategy": "indentation",
}
Run Code Online (Sandbox Code Playgroud)

设置文档

控制计算折叠范围的策略。auto如果可用,使用特定于语言的折叠策略。indentation使用基于缩进的折叠策略。