Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs 在gatsby js中使用react-md_Reactjs_Sass_Material Design_Gatsby - Fatal编程技术网

Reactjs 在gatsby js中使用react-md

Reactjs 在gatsby js中使用react-md,reactjs,sass,material-design,gatsby,Reactjs,Sass,Material Design,Gatsby,我试图在我的盖茨比JS项目中使用React材质设计(React md),但发现CSS规则没有得到应用。因此,当我导入一个组件(如按钮)并渲染该组件时,它没有任何样式 下面是我安装react md时所做的操作: 在我的gatsby config.js中,我添加了以下内容 plugins: [ 'gatsby-plugin-sass' ] 然后,在layouts>index.scss下 @import '~react-md/src/scss/react-md'; 然后我将其导入我的lay

我试图在我的盖茨比JS项目中使用React材质设计(
React md
),但发现CSS规则没有得到应用。因此,当我导入一个组件(如
按钮)并渲染该组件时,它没有任何样式

下面是我安装react md时所做的操作:

在我的
gatsby config.js
中,我添加了以下内容

plugins: [
    'gatsby-plugin-sass'
]
然后,在
layouts>index.scss下

@import '~react-md/src/scss/react-md';
然后我将其导入我的
layouts>index.js
as

import './index.scss'


当我渲染
按钮
组件时,它没有任何样式。我检查了组件,它应用了所有正确的CSS类名,但规则似乎不起作用。

添加到layouts文件夹中的
索引.scss

@import url('https://fonts.googleapis.com/cssfamily=Roboto:400,500,700|Material+Icons'); //optional
@import '~react-md/src/scss/react-md'; // Required
$md-primary-color: $md-teal-500; //optional colors
$md-secondary-color: $md-purple-a-400; //optional colors
@include react-md-everything; // Required
注:使用
@包含所有内容您可以获得整个css库

如果要最小化CSS,请根据以下格式为每个组件使用
@import

@包括反应md组件

e、 g.使用
@将react md按钮
包含到react组件的scss文件中,您要从react md导入并使用


文档:

有效!非常感谢你