Styled-component使用与修改antd的样式

styled-component 是什么?

styled-component 是一个CSS-In-JS 的函式库,使你可以在JSX 中撰写CSS code,更方便的是他可以接到component 的props 值来动态改变css 样式。

首先透过npm 安装它

npm install styled-components

我的习惯是会把styled-component 跟component 的code 拆开,最后再引入进去使用
在这里插入图片描述
基本上使用方式非常简单,styled.div 也可以替换成styled.img 或styled.h1 等任何HTML TAG。

<div style={
   
    
    {
   
    
    display:'flex'

猜你喜欢

转载自blog.csdn.net/weixin_40639095/article/details/129990082