相关疑难解决方法(0)

如何在 Storybook 6 中使用 css 模块

我的 css 模块无法与 Storybook 一起使用。没有任何错误,只是不起作用。我不明白\xc2\xb4t 出了什么问题。这是 Storybook 如何渲染按钮的图像:

\n

没有CSS的图像

\n

Button.js文件:

\n
import React from "react";\nimport PropTypes from "prop-types";\nimport style from "./styles.module.css";\n\nconst Button = ({ type, children }) => (\n  <button className={style.button}>{children}</button> \n);\n\nButton.propTypes = {\n  children: PropTypes.node.isRequired,\n  type: PropTypes.string,\n};\n\nButton.defaultProps = {\n  children: "primary",\n  type: "primary",\n};\n\nexport default Button;\n
Run Code Online (Sandbox Code Playgroud)\n

Button.stories.js文件:

\n
import React from "react";\nimport Button from "./Button";\n\nexport default {\n  component: Button,\n  title: "Test/Button",\n};\n\nconst Template = (args) => <Button {...args} />;\n\nexport const Primary = Template.bind({});\nPrimary.args = {\n  children: "xx …
Run Code Online (Sandbox Code Playgroud)

css-modules storybook

6
推荐指数
1
解决办法
7712
查看次数

标签 统计

css-modules ×1

storybook ×1