1.安装
1.npm install -g create-react-app
2.create-react-app my-app
cd my-app
nom start
安装慢配置淘宝镜像:
npm config set registry https://registry.npm.taobao.org
-- 配置后可通过下面方式来验证是否成功
npm config get registry
2.使用styled-components
cnpm i styled-components-S
styles.js
import {createGlobalStyle} from 'styled-components';
export const GlobalStyled = createGlobalStyle`
body{
background:red;
}
`
App.js
import React from 'react';
import {GlobalStyled} from './styles.js'
function App() {
return (
<div className="App">
hello
<GlobalStyled />
</div>
);
}
export default App;
3. 使用iconfont 把iconfont.css改成iconfont.js
import {createGlobalStyle} from 'styled-components';
export const IconFont = createGlobalStyle`
@font-face {font-family: "iconfont";
src: url('./iconfont.eot?t=1582527748087'); /* IE9 */
src: url('./iconfont.eot?t=1582527748087#iefix') format('embedded-opentype'), /* IE6-IE8 */
url('data:application/x-font-woff2;charset=utf-8;base64,d09GMgABAAAAAAOgAAsAAAAAB5wAAANUAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHEIGVgCDBgqCbIJYATYCJAMMCwgABCAFhG0HUBu4BhEVnJHIfhbYMXm60kVOjX3+bXFlWbucg+CBZ1u&#