【发布时间】:2019-05-13 12:38:32
【问题描述】:
我是 ReactJS 的初学者,目前我正在使用 styled-component 来设置某些模块的样式。实际上我在一个文件夹中创建了 2 个文件。一个是 style.js 我正在制作 2,3 对象,现在我想将这 3 个对象导出到我的另一个文件,名称为 2nd.js 但它对我不起作用,请你帮我如何导入 style.js反对我的文件。
Style.js 代码
import styled from 'styled-components';
export const SubText = styled.div`
font-size: 20px;
text-align: center;
padding-bottom: 30px;
width: 330px;
color: #012653;
margin: 0 auto;
font-weight: 440;
`;
export const GeneralText = styled.div`
color: red;
font-size: 26px;
font-weight: 600;
text-align: center;
min-width: 266px;
padding-bottom: 30px;
font-family: Lato, sans-serif;
margin-top: 50px;
color: #012653;
`;
export const ButtonWrapper = styled.div`
text-align: center;
margin-top: 26px;
`;
2nd.js 代码
import Style from './Style';
<GeneralText>This is dummy text </GeneralText>
【问题讨论】:
-
你需要使用类似这样的名称导入 {SubText,ButtonWrapper, GeneralText }
-
@CodeManiac 我已经尝试过,但与此同时他们给了我错误...
GeneralText is not defined -
@CodeManiac 谢谢你解决了:)
标签: javascript reactjs antd ant-design-pro