0

有可能做这样的事情CSS Modules吗?

CSS

.dateLabel {
  text-align: center;

  &.today {
    background: red;
  }
}

JS

import s from './style.scss';

return (
    <div class={`today ${s.dateLabel}`}>
     ...         
);

因为我想避免这样做:

.dateLabel {
  text-align: center;
}

.today {
  background: red;
}

JS

import s from './style.scss';

return (
    <div class={`${s.today} ${s.dateLabel}`}>
     ...         
);
4

1 回答 1

-1

您可以使用sass Ampersnad来实现这一点。

https://css-tricks.com/the-sass-ampersand/
于 2019-09-30T01:15:51.180 回答