3

我正在寻找一种将索环框架集成到使用 cli 创建的反应应用程序的方法。我想在我的应用程序中使用反应索环组件,但预处理器 SCSS 存在一些问题。今天,我尝试以多种方式集成它们,我遵循了很多教程,但它仍然无法正常工作。你知道或者你有成功将它们一起使用吗?谢谢

4

1 回答 1

3

对于索环 1.x

如果您不想将 scss 添加到项目中,grommet -css是一个不错的选择。您可以安装它并将 css 导入到您的App.js.

请注意,要自定义默认主题,您必须派生 repo,进行更改,例如在 index.scss 中包含不同的默认索环样式或调整索环 scss 变量。然后你必须更新 package.json 中的名称,运行 npm build,然后运行 ​​npm publish。

这是一个使用grommet和的示例grommet-css

import React, { Component } from 'react'

import '../../node_modules/grommet-css';
import Heading from 'grommet/components/Heading';
import Box from 'grommet/components/Box';

export default class GrommetExample extends Component {
  render() {
    return (
      <Box>
            <Heading>Hello, I'm a Grommet Component styled with <a href='https://www.npmjs.com/package/grommet-css'>grommet-css</a></Heading>
      </Box>
    )
  }
}
于 2017-11-09T21:06:20.363 回答