【问题标题】:css-loader, style-loader and typescriptcss-loader、style-loader 和 typescript
【发布时间】:2019-04-22 01:24:58
【问题描述】:

我目前正在导入由 css-loader 和 style-loader 组成的 CSS 文件。

这就是导入的样子 import './styles/index.scss';

而类名只是字符串。

我正在将我的代码转换为 TypeScript,我想知道这个设置是否与该语言兼容。有谁知道如何让它工作?

【问题讨论】:

  • 是的,兼容
  • @PlayMa256 你有一个例子吗?

标签: typescript webpack webpack-style-loader css-loader


【解决方案1】:

是的,它与打字稿兼容。

import './styles.styl';

export interface TextProps {
    text: string;
}

const Text: React.SFC<TextProps> = ({
    text: string
}) => {
    return (
        <h1>{text}</h1>
    )
};

export default Text;

【讨论】:

    猜你喜欢
    • 2017-10-10
    • 1970-01-01
    • 2020-03-13
    • 2020-01-30
    • 2020-10-09
    • 2019-04-15
    • 2015-07-27
    • 2021-10-18
    • 1970-01-01
    相关资源
    最近更新 更多