intellij-idea IntelliJ的 emmet +React-css-模块

pnwntuvh  于 2022-11-01  发布在  React
关注(0)|答案(3)|浏览(188)

我将转向react-css-modules,它要求类布局为:

<div styleName="local-class-here">

而不是传统的:

<div className="global-class-here">

如何在IntelliJ中自定义 emmet ,以便在扩展时

.my-class

它将返回以下内容?:

<div styleName="my-class">
k4ymrczo

k4ymrczo1#

没有办法做到这一点;如果您错过了此功能,请遵循WEB-28691获取更新

rseugnpd

rseugnpd2#

使用内置CSS模块,与sass一起使用https://github.com/css-modules/css-modules

// this is the only page that should import styles this way, please use getStyles() so styles are not repeated in the header
import dig from "src/style.module.scss"

// the thought has occurred to me to put this in the DropVariables file, but getStyles of a different nature exists there, oops.
// feel free to un-clobber and move this.
export function getStyles<iCSS extends {}>(overrides: iCSS = {} as iCSS): typeof dig & iCSS {
    return {
        ...dig,
        ...overrides
    }
}
ldfqzlk8

ldfqzlk83#

尝试使用patch-styles。在这种情况下,您仍将使用传统的className,并将得到相同的结果。您的代码将如下所示:

<PatchStyles classNames={styles}>
  ...
  <div styleName="my-class">
    ...
  <div>
</PatchStyles>

它会自动更新你的className而不是你。

相关问题