禁用 Spartacus 组件样式

Disable Spartacus component styles

文档指出可以跳过组件样式

Skipping Specific Component Styles Component styles are optional, because they are pulled in from the style library. Therefore, you might want to disable some standard component styles entirely. To disable standard component styles, you can add the component selectors to the $skipComponentStyles list. The following is an example that demonstrates skipping two standard components from the style library:

$skipComponentStyles: (cx-product-carousel, cx-searchbox);

$skipComponentStyles: (cx-product-carousel, cx-searchbox); Skipping specific component styles might be beneficial if you need to create styles from scratch and do not want to override specific style rules coming from the Spartacus style library.

应该在哪里做?我无法从文档中得到它。我的第一个猜测应该是全局 style.scss 但例如以下内容不起作用:

@import '~@spartacus/styles/index';
$skipComponentStyles: (header, cx-media, cx-banner, cx-category-navigation);

你几乎是对的,你只需要交换两行。 sass 变量将在 Spartacus 样式的导入中使用,否则该变量默认为空变量。因此,以下将起作用:

$skipComponentStyles: (header, cx-media, cx-banner, cx-category-navigation);
@import '~@spartacus/styles/index';