项目使用emotion

接下来记录一下项目引用emotion,还是得多练才能说我会用react喔

1.首先是安装emotion依赖包

npm i @emotion/react

npm i @emotion/styled

2.接着是组件引入emotion

// 引入emotion

import styled from "@emotion/styled”;

3.emotion渲染html标签写法

//在html代码中使用css组件:

<Container>

//html代码

</Container>


// 使用emotion 创建css组件

const Container = styled.div`

display: flex;

flex-direction: column;

align-items: center;

min-height: 100vh;

`;

`4.emotion渲染自定义组件

// Card 是antd已存在的组件

const ShadowCard = styled(Card)`

    width: 40rem;

    min-height: 56rem;

    padding: 3.2rem 4rem;

    border-radius: 0.3rem;

    box-sizing: border-box;

    box-shadow: rgba(0, 0, 0, 0.1) 0 0 10px;

    text-align: center;

`;

暂时这些够用了,不够用请参考文档

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容