其他分享
首页 > 其他分享> > React项目中使用 styled-components

React项目中使用 styled-components

作者:互联网

npm install styled-components --save

import styled from 'styled-components';
//styled.xxx表示创建xxx这个h5标签,
//后面紧接的字符串里面写的是CSS代码
export const HeaderWrapper = styled.div`
  z-index: 1;
  position: relative;
  height: 56px;
  border-bottom: 1px solid #f0f0f0;
`;

之后在APP中使用它

import React, {Component} from 'react';
import { HeaderWrapper } from './style.js';

class App extend Component{
    render() {
        return (
            <HeaderWrapper></HeaderWrapper>
        )
    }
}
export default App;

vscode 插件:vscode-styled-components

标签:vscode,React,HeaderWrapper,export,components,styled,import
来源: https://blog.csdn.net/weixin_40545119/article/details/122690476