【问题标题】:use styled component with react js使用带有 React js 的样式化组件
【发布时间】:2021-01-03 10:59:19
【问题描述】:

我在使用 react-bootstrap 和 styled component 时遇到问题,因为当我需要设置像 "Col" 这样的组件样式时,我会从这样的两个文件中导入它:

import Col from "react-bootstrap";
import Col from "styled-Component";

所以当我使用styled component 时,我不应该使用react-bootstrap??

【问题讨论】:

  • 检查this,一定会回答你的问题。下次请先做一个研究。和平

标签: reactjs react-bootstrap styled-components


【解决方案1】:

您应该可以使用不同的名称导入:

import {Col as BootstrapCol} from "react-bootstrap";
import {Col as StyledCol} from "styled-Component";

【讨论】:

  • 这就是我的意思,当我像这样使用 Col 时,它会做两项工作,我的意思是会像样式化组件和网格一样工作?
  • 你不能同时拥有一个组件,你必须选择你使用的组件,但是这个方法应该允许你同时使用来自 react 的 Col 和来自 styled 的 Col -在不同位置在同一页面中使用的组件。
猜你喜欢
  • 2021-03-21
  • 2020-12-03
  • 1970-01-01
  • 2020-09-26
  • 2020-11-05
  • 2020-04-17
  • 2021-09-06
  • 2017-05-16
  • 2020-04-02
相关资源
最近更新 更多