reactjs - 如何在 React 应用程序中使用样式化组件
问题描述
我一直在尝试在我的反应应用程序上将样式从 bulma 更改为 Styled 组件,但是在尝试在我的函数中实现它时遇到了一些问题。
import React, {FC} from 'react';
import styled from 'styled-components';
const theme = styled.div`
text-align: center;
background-color: #535151;
font-style: bold;
`;
const H1 = styled.h1`
font-size: 60pt;
font-style: Verdana;
color: black;
`;
interface HeaderProps {
title: string;
subtitle: string;
}
const Header: FC<HeaderProps> = ({title, subtitle}) =>{
return (
<>
<theme>
<H1 className="title mb-3">{title}</H1>
<h2 className="subtitles mt-0">{subtitle}</h2>
</theme>
</>
);
}
export default Header;
解决方案
import React from 'react';
import styled from 'styled-components';
const Template = styled.a`
background-color: red;
`;
export const Test = () => {
return(
<>
<Template>Hello</Template>
</>
)
}
尝试这个。
推荐阅读
- r - 分析 R 上的趋势标签时无法提取屏幕名称
- python - 创建数组时dtype = np.int和int之间的区别
- python - django server 127.0.0.1:18000 在openx 项目的浏览器上不起作用
- android - 有什么方法可以等待来自 MaterialAlertDialogBuilder 的值?安卓 - 科特林
- dart - 使用继承的对象列表
- javascript - 想要在 MongoDB 中获取给定月份的每个日期的项目数
- r - 基于一行 R 为一组中的多行改变一个变量
- pipeline - 播放按钮不适用于 git lab runner 中开发人员角色的计划主分支
- reactjs - Material UI Autocomplete getOptionSelected 功能似乎失败了,我需要指导
- php - Laravel如何连续获得相似/最多计数的记录?